home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR36
/
RENUMBER.ZIP
/
RENUMBER.S
Wrap
Text File
|
1993-06-12
|
14KB
|
412 lines
/**********************************************************************
procedure==> vmReNumber () 1.21 <==by Volker Multhopp 05/14/93
An easy way to repeatedly renumber a text or block.
returns: nothing
notes: see below
Bound to <Ctrl grey*> at end of source.
Ultra-short instructions:
Call vmReNumber() wherever you want automatic renumbering.
Some definitions:
NSTRING: A renumberable "number" string of all digits, ie 0-9; all caps,
ie A-Z; or all lower case, ie a-z; or the null string "". The nstring
is terminated with a period and preceded by a bullet.
The nstring may contain a leading tilde, ie "~", to prevent nstring
incrementing.
The nstring may contain a leading caret, ie "^", to reset the nstring
to a particular value.
Note: unless there's a leading caret ONLY THE FIRST NSTRING in a
sequence has any value meaning to the procedure-- the rest are just
placeholders!
BULLET: A special character used to mark the start of a nstring. The
default bullet is "", chr(16), which can be reset by the user to
define distinct sequences. The bullet should be a character not
otherwise used in the text. The bullets can later be removed from
the final text for printing and distribution.
DESCRIPTION OF OPERATION:
1. The procedure asks if the user would like to:
a: Renumber immediately.
b: Insert a number. If so a bullet and a period are inserted into
the text at the current location.
c: Change the bullet. If so, the bullet is changed according to the
user's wish.
2. The procedure then goes to the beginning of the text, or marked
block, and proceeds all the way to the end of the text or block. The
pre-call position is later restored.
3. The procedure finds the first bullet-nstring-period sequence. If that
nstring is empty, then it is made "1". This nstring determines the value
of all the following ones. This nstring should not be preceded by a
tilde.
4. The procedure finds the next bullet-nstring-period sequence.
a. If the new nstring begins with a caret, go back to step 3.
b. If the new ntsring begins with a tilde, it is discarded and
replaced with a tilde and the previous nstring.
c. Otherwise the new nstring is discarded. The previous nstring is
incremented by one and inserted to its place. Numbers are incremented
in the standard fashion. Alphas are similarly incremented, ie:
A,B,C,...,Y,Z,AA,AB,...,GZY,GZZ,HAA,... etc.
5. Step 4. is repeated until finished.
AN EXAMPLE. I'll demonstrate with a short, but complicated example.
Let's say you want to make a list of the animals you've owned, and you
like this format:
A. horses
A.1. arabians
A.2. quarter horses
B. goats
C. dogs
C.1. shepherds [Fig. 1.]
C.2. hounds
C.3. pointers
D. aquarium fish
Now suppose you want to add "cats" after "goats". You'll have a lot of
changes to make (Pretend the list is much longer.). But you could have
entered it as:
A. horses
~.1. arabians
~.. quarter horses
. goats
. dogs
~.^1. shepherds [Fig. 2.]
~.. hounds
~.. pointers
. aquarium fish
Well, that looks pretty abstract and ugly. As you entered it, you could
have put in the BCD23's, etc, to get the format clearer and make it more
text-like. Or you could have left out the 1's, because '1' is the default
sequence start. Anyway, the '' bullets mark one series, which uses caps
and begins with 'A', because of the 'A' by horses. The series is kept
from incrementing at the horse and dog sub-types by the tildes.
The '' bullets (chr(19)) actually represent two distinct sequences,
because the bullet is re-initialized by the caret at shepherds.
Anyway, if you call vmReNumber() (You need to call it twice actually,
since you have two different bullets), you'll get:
A. horses
~A.1. arabians
~A.2. quarter horses
B. goats
C. dogs
~C.^1. shepherds [Fig. 3.]
~C.2. hounds
~C.3. pointers
D. aquarium fish
Now that looks more like it. Still, it's ugly with the funny characters,
and the shepherds aren't even aligned. But whenever you're ready to
print, you can pull out the bullets, tildes, and carets. The shepherds
will then be aligned and the text will look like Fig. 1.
Anyway, you can now insert a ". cats" line (or "C. cats" or
"anything.cats") beneath the goats line, and again call vmReNumber() by
hitting the assigned key, or calling ExecMacro(). You'll get:
A. horses
~A.1. arabians
~A.2. quarter horses
B. goats
C. cats
D. dogs
~D.^1. shepherds [Fig. 4.]
~D.2. hounds
~D.3. pointers
E. aquarium fish
instantly. Of course, with just ten lines, it's not so impressive, but
if you had dozens or hundreds of numbers spread over many pages, the labor
savings would be considerable.
USING VMRENUMBER()'S INSERT NUMBER OPTION:
The procedure will insert a bullet-period at the current location if
you select option 'I'. It will then renumber the text ( or block).
However, if this is the first bullet, the procedure will put in the
default '1'. If you want an alphabetical sequence, or different
starting value, just back up, delete the '1', and put in what you
want. You'll also have to put in any tildes or carets 'by hand'.
SETTING THE STARTING VALUE OF A SEQUENCE:
Only the first nstring is unchanged after a renumbering. You could
start a series with "245", "aay", or whatever.
SPECIFYING DIFFERENT BULLETS:
If you use option 'C'-- Change bullet, you have to give the procedure
a non-standard ascii character to use as the new bullet. I find the
easiest way to enter abnormal characters is with the standard DOS
alt-keypad technique. Hold down <Alt> and tap <1> and <6> on the
number keypad, then release the <Alt>, you'll get chr(16). The numlock
state doesn't matter. However, this may not work if you've redefined
those keys.