[Date Prev][Date Next][Subject Prev][Subject Next][Date Index][Subject Index]

Re: Y2K bug in DATE?



Reply to note from Patricia M Godfrey  Mon, 29
Sep 2003 13:02:06 -0400

Patricia:

> Is this the Y2K bug that vers. 4.018 fixed?

Yes.

> If not, is there any way in XPL to get the equivalent of a
> Basic or xBase right$ function, storing just the last two chars
> of a 4-char year to a SG? I've looked over the recent
> discussions of parse, but both they and the docs specify the
> need for a divisor character, so to speak.

This will become moot in your case once you get v4.018, but, as a
matter of general interest, U2 includes LEFT, RIGHT, CENTER and
SUBSTRing parsing routines analogous to the eponymous functions in
Rexx.  Input/Output is via S/G 50.  For example, in pseudo-code:

JM 2.rightQ2 ;*;  S/G 50 gets "03"
+",2">JM 2.rightQ2 ;*;  S/G 50 gets "03"

Right-parsing with the native XS command can be a little dicey, but
it's doable.  The idea is, before parsing, to append to the subject
string an additional, unique string or character, i.e., one not
already contained in the subject string, then use XS with the
appropriate number of {27}X "any character" wildcards PLUS the add-
on character to extract the right end of the string into a Save/Get. 
Lop off the add-on, and you're home.  The trick is to choose an add-
on character that doesn't occur elsewhere in the string.  If you
know that the subject string is alphanumeric, it's easy; just append
a separator.  For example:

;*; Input (all numbers)
+"!">;*; Add on non-numeric character "!"
;*; Parsing separator (two wildcards plus "!")
;*; S/G 52 has "03!"
>;*; Lop off "!"; S/G 50 has "03"
;*; Verify contents of S/G 50
;*; EXit

Here's the same thing in real code; to see it work, DECODE it,
DeFine it and issue RUNCODE:

XPLeNCODE v2.0
b-gin [UNTITLED]
{<}SV50,2003{>}{<}SX50,{<}IS50{>}+"!"{>}{<}SV51,{027}X{027}X!
{>}{<}XS50,51,51,52,53{>}{<}SX50,{<}VA@52!1{>}{>}{<}PRSave/Ge
t 50 = @50{>}{<}EX{>}[cr|lf][cr|lf]
-nd
XPLeNCODE

Right-side parsing gets knottier when the subject string contains
3-byte characters (for example, functions), so that "X number of
characters" and "X number of bytes" are not the same thing.  In that
situation, U2's LEFT, RIGHT, CENTER and SUBSTR routines have the
flexibility to return the desired number of either bytes or
characters, as needed.   HELP RIGHT displays a detailed
Help screen.

-- 
Carl Distefano
cld@xxxxxxxxxxxxx
http://www.serve.com/xywwweb/