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

Re: Getting date



Reply to note from Harry Binswanger  Sun, 17 May 1998
02:39:58 -0400 (EDT)

-> Just for my edification, would you mind explaining the role of
-> the quotes in: «SX01,"«VA$DA"+«IS01»+"»"»;*; Construct the
-> «VA$DA» statement

-> And in: «SX01,«PV01»»;*; Evaluate it (S/G 01 now contains,
-> e.g., "May 16, 1998") --what do you mean by "evaluate it"? Is
-> the PV here functioning like GT?

Harry:

One of the core enhancements in 4th-generation XPL is the ability to
concatenate strings directly -- by enclosing them in double quotes --
instead of first saving them to Save/Gets. In the example, we wanted
to save a «VA$DA» statement, using the default date mask, to S/G 01,
having previously assigned the mask to 01 with «SX01,«VA$DZ»». Since
the syntax for VA$DA is «VA$DA[datemask]», we can construct the desired
statement by concatenating (stringing together) "«" [the opening
guillemet] + "VA$DA" (those 5 chars., literally) + «IS01» [the date
mask] + "»" [the closing guillemet]. «SX01,"«VA$DA"+«IS01»+"»"» simply
assigns that strung-together string to S/G 01 ("«SX01,...»").

(Note how manipulating the string directly sidesteps the knotty problem
of assigning a string with unbalanced «»'s ["«VA$DA"] to a save/get.
As long as the concatenation statement itself has balanced «»'s, you're
home free. And the code is neat, simple and compact.)

-> And in: «SX01,«PV01»»;*; Evaluate it (S/G 01 now contains,
-> e.g., "May 16, 1998") --what do you mean by "evaluate it"? Is
-> the PV here functioning like GT?

PV stands for Put Value; it evaluates what's in the save/get and "puts"
the result, either at the cursor position [«PV01»], or into a save/get
[«SX01,«PV01»»]. Assuming that the date mask in S/G 01 is "Mmmm d,
yyy", then after our previous statement «SX01,"«VA$DA"+«IS01»+"»"», S/G
01 contains, literally, «VA$DAMmmm d, yyy» -- a nice-looking piece of
XPL code, but not the end-product we want to display. What we want to
display is the evaluated *result* of «VA$DAMmmm d, yyy»; «SX01,«PV01»»
performs the evaluation, and assigns the result again to S/G 01.
Displaying that result as a status-line PRompt is then an easy matter
with «PR@01».

The best way to understand what's going on is to add "«PR@01»" to each
expression, then RUNCODE it. (I know you have RUNCODE because you're a
SmartSet user.) Specifically, DeFine each of the following lines
(substitute real «»'s, obviously), and issue RUNCODE«Helpkey»:

«SX01,«VA$DZ»»«PR@01»;*;

«SX01,"«VA$DA"+«IS01»+"»"»«PR@01»;*;

«SX01,«PV01»»«PR@01»;*;

For each line, "«PR@01»" displays the result of the preceding
expression.

I hope this helps.
-------------- Carl Distefano CLDistefano@xxxxxxxx http://users.datarealm.com/xywwweb/