Excellent.  Thanks muchly.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Ray Wurlod
Sent: Wednesday, 8 September 2004 8:04
To: [EMAIL PROTECTED]
Subject: RE: [U2] Part file algorithms - am I correct?
Importance: Low


MOD() is the remainder after integer division.  MOD(7,3) is 1, MOD(8,3) is 2, MOD(9,3) 
is 0, and so on.

SEQ() returns the ASCII code point of a character.  SEQ("A") returns 65, since "A" is 
CHAR(65).

So the algorithm takes the rightmost character of the key, using @ID[1].  You could 
also use Right(@ID,1) or your less efficient but functionally equivalent 
@ID[LEN(@ID),1] to get this character.

We then get a numeric value, being its ASCII code, using SEQ(@ID[1]).  In an NLS 
environment, you would prefer UNISEQ, which returns the numeric Unicode code point.  
This still works for numeric keys; SEQ("0") is 48, SEQ("1") is 49, SEQ("2") is 50, and 
so on.

We divide this by five (substitute appropriate number of parts) and get the remainder, 
using MOD(SEQ(@ID[1]),5).

Since this will be a number between 1 and 4, we add 1 to get a number between 1 and 5.

Hope this helps.

----- Original Message -----
From: "LeRoi Keiller" <[EMAIL PROTECTED]>
Date: Wed, 8 Sep 2004 06:40:19 +1000
To: <[EMAIL PROTECTED]>
Subject: RE: [U2] Part file algorithms - am I correct?

> Thanks guys.
> 
> Ray, I've checked our 10-part DEFINE.DF statement - you are correct; it actually 
> assigns each part from part 1, not from 0 (so I can only assume the +1 in the 
> algorithm does this, ie @ID...+1):
> 
>    DEFINE.DF MYDATA ADDING DATA_0 1 DATA_1 2 ...etc... INTERNAL "@ID[LEN(@ID),1]+1"
> 
> Are you able to tell me a little more about MOD and SEQ, or describe what the 
> algorithm does?  (Just briefly.)
> 
>    1+MOD(SEQ(@ID[1]),5)
> 
> Ross - yes, in my case (so far), the @IDs are pseudo random.
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to