Subject: | |
From: | |
Reply To: | Knox, Dave (Dallas CSC Citrix) |
Date: | Wed, 13 Oct 1999 10:50:06 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Would not A000 to A999, B000 to B999 etc. be better? Especially if sorting.
In which case I'd do something like this...
You can get the ascii of a decimal easily in PowerHouse, but not the
reverse.e.g.
define t-65 integer size 2 = 65
define X-65 char*1 = char(t-65)[2:1] ;(giving "A")
so we need to use setvar...anyway...
temp t-byte1 char*1
temp t-byte234 char*3
temp t-setvar char*80
procedure internal next-seq ;called as required...
begin
let t-byte1 = your-identifier[1:1]
let t-byte234 = ascii( ncon( your-identifier[2:3] ) + 1,4 )[2:3]
if t-byte234 = "000"
then begin
if t-byte1 < "9"
then let t-byte1 = ascii(ncon(t-byte1) + 1)
else if t-byte1 = "9"
then let t-byte1 = "A" ;assuming you want to jump the
char in between
else begin
let t-setvar = 'setvar newbyte chr(ord("' + t-byte1 +
'") + 1)'
run command d-setvar ;setvar will increment ascii
of 1st byte.
let t-byte1 = getsystemval("newbyte")
end
end
let your-identifier = t-byte1 + t-byte234
end
I have no doubt there's a tidier way to do this, but this should do what you
need. If you want the 000A you were talking about, then you'll need to
juggle it to reference the different bytes...
Regards
Dave
> ----------
> From:
> [log in to unmask][SMTP:[log in to unmask]]
> Sent: Wednesday, October 13, 1999 6:32 AM
> To: [log in to unmask]
> Subject: Counting from 9999 to 000A?
>
> Dear listers
>
> I am looking for an algorithmus, which solves the following problem and
> could be used within POWERHOUSE.
>
> We have an identifier which ranges from 1-9999 (but is stored as character
> in the database). We are about to reach the limit, so I would like to
> store
> 000A after 9999 and so on, rather then changing all the database
> structures
> and depending programs.
>
> Thank you for any help,
> Friedrich
>
|
|
|