The following statements right-justify the shorter of the numeric strings
A$
and
B$
and fill
it
with
leading zeros until
it
equals the length of the longer string. X
is
assigned ta the length of A$. and Y ta the length of B$:
313
BLFtt-lI<$="
413
X=LEt-l(Ft$):Y=LEt-l(B$)
513
IF
X<Y
THEt-l
Ft$=LEFT$(BLFtt-lK$,Y-X)+Ft$
613
IF
Y<X
THEt-l
B$=LEFT$(BLFtt-lK$.X-Y)+B$
BLANK$ in line 30
is
a buffer string ta fill the shorter numeric string
with
blanks.
Lines 50 and 60 use the
LEN
function ta compare X (the length of A$) ta Y (the
length of
B$l. and subtract the length of the smaller string from the length of the
larger string. In our example
B$
is
shorter than A$,
sa
the length of
B$
is
subtracted from the length of A$.
613
IF
Y<X
THEt-l
B$=LEFT$(BLFtt-lK$.X-Y)+B$
-...-
Length
of
smaller
string subtracted
from
length
of
larger string
If the length of
A$
is
16 digits and the length of B$
is
8 digits, the difference
is
8 digits:
A$
111213141516171819101112131415161
x=
16
1
X-y
=81
B$
15171914131517121
y = 8
16-8
= 8
The number of blanks concatenated onto the front of
B$
is
the difference of
the
two
lengths. Since the difference
is
8,
eight blanks are taken fram BLANK$ ta
fill the shorter string. Blanks are then concatenated ta the front of the shorter
string
B$
with
the following statement:
LEFT$(BLANK$(X
-Y))+B$
The procedure
is
as
follows:
B$=LEFT$(BLANK$,X-Y) +B$
B$=LEFT$(BLANK$.16-8) +B$
B$=LEFT$(BLANK$.S)
+B$
B$=LEFT$(j16I16I16I16I16!16I16I16I16I16I16I16I16I16I16I16I.8)
+B$
B$-I16I16I16J16I16I16I16I161
+=15=17=\91"-41=31""51=71""'21
B$-I16I16I16I16I16I16I16I1615171914131517121
A$=11121314151617lsJ91
0
11121314/5/61
B$=I16I16I16/16I16I16I16I1615171914131517/2/
16
digits
16
digits
191