Subject: | |
From: | |
Reply To: | |
Date: | Tue, 16 Feb 1999 14:39:53 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Klaus Bieber asks:
> I would like to use the CI to create file names based on a YYMM format
> depending on the current value of HPYEAR & HPMONTH.
No problem. The mind-block part is that you don't need a function
to convert the number to a string! (I remember going through the
same thing in the beginning.)
Here's the "convert-to-string" syntax:
# set up the number
setvar mynum 10
# do the conversion
setvar mystring "!mynum"
The "gotcha" with HPYEAR and HPMONTH (and HPDATE) is that each can be
one OR two digits, and the string conversion uses the minimum length.
If you try something like
setvar myfile "FILE!hpyear!hpmonth"
or the more obvious
setvar myfile "FILE" + "!hpyear" + "!hpmonth"
then this month's entry is
setvar myfile "FILE" + "99" + "2"
or FILE992. Come January 2000, it gets worse:
setvar myfile "FILE" + "0" + "1"
or FILE01.
The way around this is to *force* the string version of HPYEAR and
HPMONTH to have a leading zero if necessary. This can be coded as:
setvar myfile "FILE" + rht("0!hpyear",2) + rht("0!hpmonth",2)
To see how this works, let's just look at the function for HPYEAR.
For 1999, we have
rht("0!HPYEAR",2)
or rht("099",2)
or 99 after extracting the right-most two digits
For 2000, it becomes
rht("0!HPYEAR",2)
or rht("00",2)
or 00
That's a bit (!) long-winded, but hopefully it makes sense.
--Glenn
.......................................................................
Item Subject: cc:Mail Text
|
|
|