This is the code that I have so far, but I’m not getting the correct
results.
ANS1 = BAD.REC<10>[1,1] ;* Checkwriter State
ANS2 = BAD.REC<10>[2,1]
BAD.STATE = SEQ(ANS1) : SEQ(ANS2)
*
CHECK.AMT = BAD.REC<19> ;* Check Amount
*
FOR D = 1 TO NO.OF.DESKS
DESK.NO = GREC<3,D>
*
ANS1 = GREC<4,D>[1,1]
ANS2 = GREC<4,D>[2,1]
FROM.VAR = SEQ(ANS1) : SEQ(ANS2)
*
ANS1 = GREC<5,D>[1,1]
ANS2 = GREC<5,D>[2,1]
TO.VAR = SEQ(ANS1) : SEQ(ANS2)
*
IF (FROM.VAR >= BAD.STATE) AND (TO.VAR <= BAD.STATE) THEN
GREC<6,D> += 1
GREC<7,D> += CHECK.AMT
GREC<8,D> = ID
END
NEXT D
Thanks,
-Peter G.
Is "State" a two character alpha that represents a US state code
abbreviation? If so then the problem is likely that you're generating
numeric values that don't fall within the sequential range and/or
order that you expect, due to their position in the alphabet.
Alphabetically, Arizona comes before Arkansas, but their state codes
are AZ and AR, which if converted to ASCII would put them in the
opposite order. The same for Indiana (IN) and Iowa (IA).
It would likely be better to set up an array with all the state codes
in the correct order, then just LOCATE on them to see if their
position is within your desired range.
--
Kevin Powick
I didn't think about the different in the spelling vs. the
abbreviations....
However, this goes beyond the state. This was a simple example of what
I need. Instead of states, I'll be using individual's name (John Doe,
Jane Smith....)
This is my issue. I have 10, 13, or 20 users. This number of users can
change any day. I have a database of 10,000 records and attribute 1
has an individual's name. I want to distribute the 10,000 records to
those 10 users. Each user will have an assigned alpha range. The range
is user driven so I can't hard conditional logic.
User# Range
110 AA - AZ
120 BB - BZ
130 CC - CZ
140 DD - DZ
150 EE - EZ
160 FF - FZ
170 GG - GZ
180 HH - HZ
190 II - ZZ
-Peter G.
I must be loosing my mind and need a break. My problem was the IF
statement. The statement was reversed. It should be:
IF (BAD.STATE >= FROM.VAR) AND (BAD.STATE <= TO.VAR) THEN
Thanks Kevin for looking into this.
-Peter G.
I code range comparisons like this:
IF (FROM.VAR <= BAD.STATE) AND (BAD.STATE <= TO.VAR) THEN
Makes it easier (for me) to see that the condition we're
looking for is BAD.STATE between FROM.VAR and TO.VAR.
I'd change the variable names, too:
IF (LOW.STATE <= MY.STATE) AND (MY.STATE <= HIGH.STATE) THEN
HTH.
--
frosty
>I'd change the variable names, too:
>IF (LOW.STATE <= MY.STATE) AND (MY.STATE <= HIGH.STATE) THEN
I was thinking along the same lines. Here we are with an explanation
from the developer about what the code means and it doesn't seem to
match the variable names. Imagine someone coming at this without the
advantage of the presence of the original developer.
I'll also add that it's probably not necessary to SEQ() on text to do
a comparison, and it may even get you in trouble. MV BASIC
automatically does a sort using the ASCII value of text, so this:
IF "A" < "B" THEN CRT "A<B"
is equivalent to this:
IF SEQ("A") < SEQ("B") THEN CRT "A<B"
However, while D3 is not case-sensitive, I believe this will produce
different results:
IF SEQ("a") < SEQ("B") THEN CRT "A<B"
because lower-case A is 97 and upper-case A is 65.
So if you're using SEQ, UCASE or LCASE all text before comparison.
HTH
T
> I must be loosing my mind and need a break. My problem was the IF
> statement. The statement was reversed. It should be:
>
> IF (BAD.STATE >= FROM.VAR) AND (BAD.STATE <= TO.VAR) THEN
>
> Thanks Kevin for looking into this.
Well, at least you found it. I just assumed your IF/THEN range logic
was what you desired.
--
Kevin Powick