Why doesn't this code work? 
Author Message
 Why doesn't this code work?

Using C5aEE ABC.  I have the following code in an embed and it doesn't
work.

        CLEAR(ATowed:Record, -1)
        ATO:LicenseNum = Tow:LicenseNum
        SET(ATowed,ATO:DescLicNum_Key)
        ACCESS:Atowed.NEXT()
        IF NOT ERRORCODE() AND ATO:LicenseNum = Tow:LicenseNum
             TOW:VinNum =
ATO:VinNum
             TOW:YearOfVehicle = ATO:YearOfVehicle
             TOW:MakeOfVehicle = ATO:MakeOfVehicle
             TOW:ModelOfVehicle = ATO:ModelOfVehicle
             Display()
             IF ATO:DateTowed > TODAY() - 5 and LOC:ValidateFlag = 0
                LOC:ValidateFlag = 1
                DupWarning
             END
        END

If I comment out the IF NOT ERRORCODE() like below it works except for
the part in the nested IF statement.

        CLEAR(ATowed:Record, -1)
        ATO:LicenseNum = Tow:LicenseNum
        SET(ATowed,ATO:DescLicNum_Key)
        ACCESS:Atowed.NEXT()
!        IF NOT ERRORCODE() AND ATO:LicenseNum = Tow:LicenseNum
             TOW:VinNum = ATO:VinNum
             TOW:YearOfVehicle = ATO:YearOfVehicle
             TOW:MakeOfVehicle = ATO:MakeOfVehicle
             TOW:ModelOfVehicle = ATO:ModelOfVehicle
             Display()
             IF ATO:DateTowed > TODAY() - 5 and LOC:ValidateFlag = 0
                LOC:ValidateFlag = 1
                DupWarning
             END
!        END

Any suggestions would be appreciated.

TIA

Gary



Thu, 15 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
Hi Gary,
A couple of things. The Clear statement clearing the record to anything
but zeros I think will give anamalous results. Secondly you can't test for
errorcode as a result of a ABC Next(). I would code this like this

Clear(ATO:Record)
ATO:LicenseNum = Tow:LicenseNum
Set(ATO:DescLicNum_Key,ATO:DescLicNum_Key)
IF Not Access:ATowed.Next() and ATO:LicenseNum = Tow:LicenseNum
    Do TheRestOfTheAssignments.

HTH

Quote:

> Using C5aEE ABC.  I have the following code in an embed and it doesn't
> work.

>         CLEAR(ATowed:Record, -1)
>         ATO:LicenseNum = Tow:LicenseNum
>         SET(ATowed,ATO:DescLicNum_Key)
>         ACCESS:Atowed.NEXT()
>         IF NOT ERRORCODE() AND ATO:LicenseNum = Tow:LicenseNum
>              TOW:VinNum =
> ATO:VinNum
>              TOW:YearOfVehicle = ATO:YearOfVehicle
>              TOW:MakeOfVehicle = ATO:MakeOfVehicle
>              TOW:ModelOfVehicle = ATO:ModelOfVehicle
>              Display()
>              IF ATO:DateTowed > TODAY() - 5 and LOC:ValidateFlag = 0
>                 LOC:ValidateFlag = 1
>                 DupWarning
>              END
>         END

> If I comment out the IF NOT ERRORCODE() like below it works except for
> the part in the nested IF statement.

>         CLEAR(ATowed:Record, -1)
>         ATO:LicenseNum = Tow:LicenseNum
>         SET(ATowed,ATO:DescLicNum_Key)
>         ACCESS:Atowed.NEXT()
> !        IF NOT ERRORCODE() AND ATO:LicenseNum = Tow:LicenseNum
>              TOW:VinNum = ATO:VinNum
>              TOW:YearOfVehicle = ATO:YearOfVehicle
>              TOW:MakeOfVehicle = ATO:MakeOfVehicle
>              TOW:ModelOfVehicle = ATO:ModelOfVehicle
>              Display()
>              IF ATO:DateTowed > TODAY() - 5 and LOC:ValidateFlag = 0
>                 LOC:ValidateFlag = 1
>                 DupWarning
>              END
> !        END

> Any suggestions would be appreciated.

> TIA

> Gary

--
! Jim Katz
! Certified Clarion Developer
! Author: ABC DLL Toolkit  Maintainer: DEF for ABC,DET for Legacy
! Web Site: http://www.iag.net/~jimkatz/
! Company:  iTradeZone,Inc.
! Using Clarion for Windows - Always looking for the simpler solution.


Thu, 15 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
1. Subtlest problem I noticed is
Quote:
>        SET(ATowed,ATO:DescLicNum_Key)

This is saying read the file in record order, starting at the first matching
record for that key (might work in your situation but you'd be unlucky if it
did - once something changed and the code suddenly failed, you wouldn't end
up looking in the right place). Never do this! Should be
        SET(ATO:DescLicNum_Key,ATO:DescLicNum_Key)

2. Your ERRORCODE() test won't work, since ACCESS:Atowed.NEXT() doesn't use
errorcode. Instead it returns a non-zero error.
IF ACCESS:Atowed.NEXT()
   next test and any action
END !IF ACCESS:Atowed.NEXT()

That's all I saw at first glance.

Regards,
Warren Marshall
A-TEK Systems

Quote:

>Using C5aEE ABC.  I have the following code in an embed and it doesn't
>work.

>        CLEAR(ATowed:Record, -1)
>        ATO:LicenseNum = Tow:LicenseNum
>        SET(ATowed,ATO:DescLicNum_Key)
>        ACCESS:Atowed.NEXT()
>        IF NOT ERRORCODE() AND ATO:LicenseNum = Tow:LicenseNum
>             TOW:VinNum =
>ATO:VinNum
>             TOW:YearOfVehicle = ATO:YearOfVehicle
>             TOW:MakeOfVehicle = ATO:MakeOfVehicle
>             TOW:ModelOfVehicle = ATO:ModelOfVehicle
>             Display()
>             IF ATO:DateTowed > TODAY() - 5 and LOC:ValidateFlag = 0
>                LOC:ValidateFlag = 1
>                DupWarning
>             END
>        END

>If I comment out the IF NOT ERRORCODE() like below it works except for
>the part in the nested IF statement.

>        CLEAR(ATowed:Record, -1)
>        ATO:LicenseNum = Tow:LicenseNum
>        SET(ATowed,ATO:DescLicNum_Key)
>        ACCESS:Atowed.NEXT()
>!        IF NOT ERRORCODE() AND ATO:LicenseNum = Tow:LicenseNum
>             TOW:VinNum = ATO:VinNum
>             TOW:YearOfVehicle = ATO:YearOfVehicle
>             TOW:MakeOfVehicle = ATO:MakeOfVehicle
>             TOW:ModelOfVehicle = ATO:ModelOfVehicle
>             Display()
>             IF ATO:DateTowed > TODAY() - 5 and LOC:ValidateFlag = 0
>                LOC:ValidateFlag = 1
>                DupWarning
>             END
>!        END

>Any suggestions would be appreciated.

>TIA

>Gary



Thu, 15 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?

Quote:

> Hi Gary,
> A couple of things. The Clear statement clearing the record to anything
> but zeros I think will give anamalous results. Secondly you can't test for
> errorcode as a result of a ABC Next(). I would code this like this

> Clear(ATO:Record)
> ATO:LicenseNum = Tow:LicenseNum
> Set(ATO:DescLicNum_Key,ATO:DescLicNum_Key)
> IF Not Access:ATowed.Next() and ATO:LicenseNum = Tow:LicenseNum
>     Do TheRestOfTheAssignments.

Jim and Warren

Thanks for the suggestions but it still doesn't work.  Some info I didn't
include in my first message.  Atowed is an alias for Towed.  The code is used
in an update form for the Towed file and when the user enters a license number
I want to go look in the alias file, Atowed, and see if this license number
has been entered before.  The code is in the Accepted embed for
TOW:LicenseNum.  This program is a 2003 to C5 ABC conversion.  The code, 2003
style, worked fine.  But for some reason it won't work in C5 ABC.  Extremely
frustrating.  If it were not for the fact that this is a humongus update form
with tabs the appear and disappear and fields that disable and enable plus
tons of embedded code I would rebuild it from scratch.

I created a test app with a wizard generated browse and update form on Towed.
Except for the problem code there is no other embed code in the either the
browse or form.  It doesn't work.  It doesn't find the appropriate record even
when there is only one record in the file.

This is the code I used.

         Clear(ATO:Record)
         ATO:LicenseNum = Tow:LicenseNum
         Set(ATO:DescLicNum_Key,ATO:DescLicNum_Key)
         IF NOT Access:ATowed.Next() and ATO:LicenseNum = Tow:LicenseNum
             TOW:VinNum = ATO:VinNum
             TOW:YearOfVehicle = ATO:YearOfVehicle
             TOW:MakeOfVehicle = ATO:MakeOfVehicle
             TOW:ModelOfVehicle = ATO:ModelOfVehicle
             Display()
        END

Any other suggestions?

Thanks again.

Gary



Thu, 15 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
Hi Neal

If the record is there I want to get it.  If it is not there I don't want
to do anything.  I'm not real familiar with tryfetch.  I'll take a look at
it and see if it might work.

Thanks

Gary

Quote:

> Hi Gary
> If I understand correctly you are setting a key and trying to get the
> record.
> If it exists already you do something otherwise you do something else.
> Is this correct?
> If so what about setting the key values and then using
> tryfetch(Ato:DescLicNum_Key)
> JAT. I may have misunderstood your aim.
> regards
> Neal



Thu, 15 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?

Quote:

> Hi Gary,
> A couple of things. The Clear statement clearing the record to anything
> but zeros I think will give anamalous results. Secondly you can't test for
> errorcode as a result of a ABC Next(). I would code this like this

> Clear(ATO:Record)
> ATO:LicenseNum = Tow:LicenseNum
> Set(ATO:DescLicNum_Key,ATO:DescLicNum_Key)
> IF Not Access:ATowed.Next() and ATO:LicenseNum = Tow:LicenseNum
>     Do TheRestOfTheAssignments.

> HTH

Hi Jim

After some more fooling around with it I can get it to work but not properly.
If I delete the Clear(ATO:Record) line the first time the code executes it
doesn't work.  However after that it works every time.  Doesn't make any
difference if the record was there or not on the first attempt on all
subsequent attempts it works.

One other thing.  My key is:

    DescLicNum_Key
        LicenseNum - Ascending
        DateTowed - Descending

If I make both ascending it works perfectly.  Seems that it has trouble
dealing with the descending key for some reason.  I'm going to test this some
more and if it is the descending key I'll post another message in the Drivers
newsgroup and see if anyone responds.  It might be a bug.

Gary



Thu, 15 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
Hi Gary
If I understand correctly you are setting a key and trying to get the
record.
If it exists already you do something otherwise you do something else.
Is this correct?
If so what about setting the key values and then using
tryfetch(Ato:DescLicNum_Key)
JAT. I may have misunderstood your aim.
regards
Neal


Fri, 16 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
Hi Gary
I'd say tryfetch is exactly what you need.
something like this

if access:YourFile.TryFetch(yourFileKey) <> level:benign
   ! do whatever you need to do
end

regards
Neal



Fri, 16 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
CLEAR(ATO:LicenseNum)    !clear to zero/space
CLEAR(ATO:DateTowed,1)    !clear to high value

Regards,
Warren Marshall



Fri, 16 Nov 2001 03:00:00 GMT  
 Why doesn't this code work?
Warren

Thanks for the advise.  I'll give these two a try.  

Gary

Quote:

> CLEAR(ATO:LicenseNum)    !clear to zero/space
> CLEAR(ATO:DateTowed,1)    !clear to high value

> Regards,
> Warren Marshall




Fri, 16 Nov 2001 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Why doesn't this subclass code work?

2. why doesn't this hold() code work?

3. Why this code doesn't work....

4. Why this code doesn't work...

5. quirks in vrml - why doesn't this code work?

6. List issue aka: "Why doesn't this code work?"

7. BLT installs but doesn't work, and TkTable doesn't build

8. Help - why doesn't this conjunction work?

9. Why doesn't this function work?

10. Why doesn't this equate work

11. Why doesn't the socket always work ?

12. why doesn't FILE{Prop:label} work?

 

 
Powered by phpBB® Forum Software