Groups > Superbase > Superbase 2 programming > Re: SET INDEX ALL




Re: SET INDEX ALL

Re: SET INDEX ALL
Tue, 06 Jun 2006 11:53:36 -040
On Tue, 06 Jun 2006 09:30:54 -0400, Ian Stephenson <ian@soeasy.co.nz>
wrote:

> FILE "FRETAIL":INDEX "RetailClient_No"
>           IF LOOKUP (RCN%,RetailClient_No.FRETAIL) THEN
>               SET INDEX ALL
>               SELECT CURRENT LOCK FILE "FRETAIL"
>               IF RCN% <> RetailClient_No.FRETAIL THEN
>                    REQUEST "There is a problem. The client number =
" + STR$
> (RCN%,"999999"),"but we are looking at =" + STR$
> (RetailClient_No.FRETAIL,"999999"),100
>                    REQUEST "I will cancel the procedure","If
this persists
> please call support on 07 572-1821",100
>                    Fail$ = "Y"
>               END IF

Let me se...

INDEX RetailClient_No sets the current index.

The LOOKUP moves NOT the current index pointer, but the one specified in the
second argument, but since RetailClient_No is already the current index this
should be ok.

The SELECT command should also set the same pointer in RetailClient_No, so
that's ok I guess.

SET INDEX ALL moves all the other record pointers to whatever record is current
in the current index. I would put that last:
Move
  SET INDEX ALL
after the
  SELECT CURRENT LOCK FILE "FRETAIL"

But here is your real problem I think: check the format of the number in the
field. I believe I've had this problem when an automatic variable (%) has not
matched the field contents like this:
variable% = 1123 (NUMBASE is "99999999")
field =    1,123.1230 (the format string in .SBD is like
"-,99999999.0000"
(variable% = field) = false
My problem was probably extra decmimal values that were not read in the variable
for some reason. At least that's what showed up when I tested it for about three
days!

Your test request formats them the same, so you will not know it. Try this:

test1$ = str$(RCN,".")
test2$ = str$(RetailClient_No,".")
REQUEST test1$,test2$

-and don't bother to test this first with "<>"...

You should be able to work out a way to ensure that the search key is in the
right format to find the record. Probably just change the current NUMBASE
setting to match what it says for that field in the SBD.

I'll be interested to know if this does the trick.

Peter
-- 
Post Reply
SET INDEX ALL
Wed, 7 Jun 2006 01:30:54 +1200
Hi

I perform a lookup on a current file but sometimes the lookup works but then 
fails to keep the pointre on the record it found.
I trap the issue and make the procedure fail.
Anyone see how I could improve this code?

Thanks in advance :)

FILE "FRETAIL":INDEX "RetailClient_No"
          IF LOOKUP (RCN%,RetailClient_No.FRETAIL) THEN
              SET INDEX ALL
              SELECT CURRENT LOCK FILE "FRETAIL"
              IF RCN% <> RetailClient_No.FRETAIL THEN
                   REQUEST "There is a problem. The client number = "
+ STR$ 
(RCN%,"999999"),"but we are looking at =" + STR$ 
(RetailClient_No.FRETAIL,"999999"),100
                   REQUEST "I will cancel the procedure","If this
persists 
please call support on 07 572-1821",100
                   Fail$ = "Y"
              END IF
more code here but not relevant


 

Post Reply
Re: SET INDEX ALL
Thu, 8 Jun 2006 11:56:24 +1200
Thanks Peter, I like your logic. This has been a bit of a problem for a 
while and causes us a bit of a recon problem every now and then. It only 
happens one out of thousands of transactions but when it does, we no longer 
balance. Will let you know progress.

Cheers Ian

"Peter Barus" <peter@visualpricing.com> wrote in message 
news:op.taqefmtppcvzm2@tetsumaru...
> On Tue, 06 Jun 2006 09:30:54 -0400, Ian Stephenson <ian@soeasy.co.nz>

> wrote:
>
>> FILE "FRETAIL":INDEX "RetailClient_No"
>>           IF LOOKUP (RCN%,RetailClient_No.FRETAIL) THEN
>>               SET INDEX ALL
>>               SELECT CURRENT LOCK FILE "FRETAIL"
>>               IF RCN% <> RetailClient_No.FRETAIL THEN
>>                    REQUEST "There is a problem. The client number
= " + 
>> STR$
>> (RCN%,"999999"),"but we are looking at =" + STR$
>> (RetailClient_No.FRETAIL,"999999"),100
>>                    REQUEST "I will cancel the
procedure","If this 
>> persists
>> please call support on 07 572-1821",100
>>                    Fail$ = "Y"
>>               END IF
>
> Let me se...
>
> INDEX RetailClient_No sets the current index.
>
> The LOOKUP moves NOT the current index pointer, but the one specified in 
> the second argument, but since RetailClient_No is already the current 
> index this should be ok.
>
> The SELECT command should also set the same pointer in RetailClient_No, so

> that's ok I guess.
>
> SET INDEX ALL moves all the other record pointers to whatever record is 
> current in the current index. I would put that last:
> Move
>  SET INDEX ALL
> after the
>  SELECT CURRENT LOCK FILE "FRETAIL"
>
> But here is your real problem I think: check the format of the number in 
> the field. I believe I've had this problem when an automatic variable (%) 
> has not matched the field contents like this:
> variable% = 1123 (NUMBASE is "99999999")
> field =    1,123.1230 (the format string in .SBD is like
"-,99999999.0000"
> (variable% = field) = false
> My problem was probably extra decmimal values that were not read in the 
> variable for some reason. At least that's what showed up when I tested it 
> for about three days!
>
> Your test request formats them the same, so you will not know it. Try 
> this:
>
> test1$ = str$(RCN,".")
> test2$ = str$(RetailClient_No,".")
> REQUEST test1$,test2$
>
> -and don't bother to test this first with "<>"...
>
> You should be able to work out a way to ensure that the search key is in 
> the right format to find the record. Probably just change the current 
> NUMBASE setting to match what it says for that field in the SBD.
>
> I'll be interested to know if this does the trick.
>
> Peter
> -- 
> "Oboslete power corrupts obsoletely" - T.H. Nelson 

Post Reply
about | contact