TCursor.Locate() and TCursor.qLocate() both fail 
Author Message
 TCursor.Locate() and TCursor.qLocate() both fail

Hello everyone,

The LandCur.Locate in the following example always returns FALSE.
LandCur is a global TCursor (declared via the Methods/Var menu),
and it was opened with:

IF NOT LandCur.Open("LANDEN.DB") THEN
  msgStop("Could not open database","LANDEN.DB")
ENDIF

LANDEN.DB has a smallint field LandCodeBevReg.
LandCur.FieldNo("LandCodeBevReg") returns 1, so the field is found.
LandCur.Locate(1,"... also fails.
This is the key field, so I changed to using qLocate(), but even this
always returns FALSE (for all tested values of nCountry).

I must be missing something here...

Bye,
Jan

proc EtnCode(nCountry SmallInt) String;
  var
    Result   String
  endvar

  IF nCountry = 0 THEN
    Result = "ONB"
  ELSE
    IF LandCur.Locate("LandCodeBevReg",nCountry) THEN
      Result = LandCur.EtnCode
    ELSE
      Result = "ONB"
    ENDIF
  ENDIF  
  RETURN Result
endproc   ; EtnCode

-----------------------------------------------------------------------

P.O. Box 697              2300 RA  Leiden            The Netherlands
-----------------------------------------------------------------------
** Specialists in multimedia software for education and presentation **
-----------------------------------------------------------------------
Usage of this email address for commercial purposes costs US$ 50 per
message. By using this email address you agree to this condition.
-----------------------------------------------------------------------



Sat, 15 Apr 2000 03:00:00 GMT
 TCursor.Locate() and TCursor.qLocate() both fail

Quote:

> Hello everyone,

> The LandCur.Locate in the following example always returns FALSE.
> LandCur is a global TCursor (declared via the Methods/Var menu),
> and it was opened with:

> IF NOT LandCur.Open("LANDEN.DB") THEN
>   msgStop("Could not open database","LANDEN.DB")
> ENDIF

> LANDEN.DB has a smallint field LandCodeBevReg.
> LandCur.FieldNo("LandCodeBevReg") returns 1, so the field is found.
> LandCur.Locate(1,"... also fails.
> This is the key field, so I changed to using qLocate(), but even this
> always returns FALSE (for all tested values of nCountry).

> I must be missing something here...

> Bye,
> Jan

I tryed you code an it worked fine for me. The only thing you didn't
include is the actual call to the proc, but since it should give an
error if the types are incompatible, I can't see that being a problem.
I have had code that wouldn't run even though it should. The cause was a
broken form. Try creating a new blank form re create all the objects on
the form(do not copy any objects from your current form). Then copy the
text of you Object pal code over.

Good Luck
FMJ



Sat, 15 Apr 2000 03:00:00 GMT
 TCursor.Locate() and TCursor.qLocate() both fail

Quote:

> Hello everyone,

> The LandCur.Locate in the following example always returns FALSE.
> LandCur is a global TCursor (declared via the Methods/Var menu),
> and it was opened with:

> IF NOT LandCur.Open("LANDEN.DB") THEN
>   msgStop("Could not open database","LANDEN.DB")
> ENDIF

> LANDEN.DB has a smallint field LandCodeBevReg.
> LandCur.FieldNo("LandCodeBevReg") returns 1, so the field is found.
> LandCur.Locate(1,"... also fails.
> This is the key field, so I changed to using qLocate(), but even this
> always returns FALSE (for all tested values of nCountry).

> I must be missing something here...

> Bye,
> Jan

Just another thought on this. Since you are using a global tcursor is it
possible that you have a filter set on the tcursor? On the newer
versions of Paradox the form will retain a filter even if you close the
form and exit Paradox. I would put a msginfo in the proc and verify that
the tcursor has the records you think it does, that your ncountry
variable have the value you think it does.

ie msginfo(ncountry,landcur.nrecords())

FMJ



Sat, 15 Apr 2000 03:00:00 GMT
 TCursor.Locate() and TCursor.qLocate() both fail

<snip>

Quote:
> There are no filters, I have the expected data (traced it through the
> de{*filter*}). I'll what creating a new form does.
> The actual procedure call is:

>      cEtn   = EtnCode(PupilCur.Geboorteland)

> with Geboorteland a SmallInt (as the watch window confirms for nCountry).

> Bye,
> Jan

Have you tryed passing a hard coded, know good value?
ie    cEtn = EtnCode(7)

Also, you say the form returns FALSE. Does it actually return the value
FALSE or do you mean it returns "ONB"? If it is the latter, what type is
cEtn declared as?

FMJ



Sun, 16 Apr 2000 03:00:00 GMT
 TCursor.Locate() and TCursor.qLocate() both fail


Quote:

>> The LandCur.Locate in the following example always returns FALSE.
>> LandCur is a global TCursor (declared via the Methods/Var menu),
>> and it was opened with:

>> IF NOT LandCur.Open("LANDEN.DB") THEN
>>   msgStop("Could not open database","LANDEN.DB")
>> ENDIF

>> LANDEN.DB has a smallint field LandCodeBevReg.
>> LandCur.FieldNo("LandCodeBevReg") returns 1, so the field is found.
>> LandCur.Locate(1,"... also fails.
>> This is the key field, so I changed to using qLocate(), but even this
>> always returns FALSE (for all tested values of nCountry).

>Just another thought on this. Since you are using a global tcursor is it
>possible that you have a filter set on the tcursor? On the newer
>versions of Paradox the form will retain a filter even if you close the
>form and exit Paradox. I would put a msginfo in the proc and verify that
>the tcursor has the records you think it does, that your ncountry
>variable have the value you think it does.

There are no filters, I have the expected data (traced it through the
de{*filter*}). I'll what creating a new form does.
The actual procedure call is:

     cEtn   = EtnCode(PupilCur.Geboorteland)

with Geboorteland a SmallInt (as the watch window confirms for nCountry).

Bye,
Jan

-----------------------------------------------------------------------

P.O. Box 697              2300 RA  Leiden            The Netherlands
-----------------------------------------------------------------------
** Specialists in multimedia software for education and presentation **
-----------------------------------------------------------------------
Usage of this email address for commercial purposes costs US$ 50 per
message. By using this email address you agree to this condition.
-----------------------------------------------------------------------



Sun, 16 Apr 2000 03:00:00 GMT
 TCursor.Locate() and TCursor.qLocate() both fail

Quote:

> Hello everyone,

> The LandCur.Locate in the following example always returns FALSE.
> LandCur is a global TCursor (declared via the Methods/Var menu),
> and it was opened with:

> IF NOT LandCur.Open("LANDEN.DB") THEN
>   msgStop("Could not open database","LANDEN.DB")
> ENDIF

> LANDEN.DB has a smallint field LandCodeBevReg.
> LandCur.FieldNo("LandCodeBevReg") returns 1, so the field is found.
> LandCur.Locate(1,"... also fails.
> This is the key field, so I changed to using qLocate(), but even this
> always returns FALSE (for all tested values of nCountry).

> I must be missing something here...

> Bye,
> Jan

> proc EtnCode(nCountry SmallInt) String;
>   var
>     Result   String
>   endvar

>   IF nCountry = 0 THEN
>     Result = "ONB"
>   ELSE
>     IF LandCur.Locate("LandCodeBevReg",nCountry) THEN
>       Result = LandCur.EtnCode
>     ELSE
>       Result = "ONB"
>     ENDIF
>   ENDIF
>   RETURN Result
> endproc   ; EtnCode

> -----------------------------------------------------------------------

> P.O. Box 697              2300 RA  Leiden            The Netherlands
> -----------------------------------------------------------------------
> ** Specialists in multimedia software for education and presentation **
> -----------------------------------------------------------------------
> Usage of this email address for commercial purposes costs US$ 50 per
> message. By using this email address you agree to this condition.
> -----------------------------------------------------------------------

Jan,
If the table being searched is password protected, the password must be
active for a locate to work.
Hope this is the answer!
--

"When you stop learning, you start to die."


Tue, 18 Apr 2000 03:00:00 GMT
 TCursor.Locate() and TCursor.qLocate() both fail

Problem solved.

As usual ;-), the error was not in the code structure or the programming
language, but in the programmer: I thought my country codes had been converted
from one list to another, and consequently I was doing the Locate in the wrong
field. None of the values in the first field ever occurred in the second
field, hence the consequent 'failure' of the locate.

Very big OOPS.

Thanks all for thinking along...
Jan

-----------------------------------------------------------------------

P.O. Box 697              2300 RA  Leiden            The Netherlands
-----------------------------------------------------------------------
** Specialists in multimedia software for education and presentation **
-----------------------------------------------------------------------
Usage of this email address for commercial purposes costs US$ 50 per
message. By using this email address you agree to this condition.
-----------------------------------------------------------------------



Wed, 19 Apr 2000 03:00:00 GMT
 
 [ 7 post ] 

 Relevant Pages 

1. Locate and TCursor versus Insert Query

2. Date problem in TCursor Locate

3. I am Curious - Locate and Tcursors

4. TCursor "Locate" speed

5. Response time too long using TCursor.locate

6. TCursor and the locate method

7. Continued: P. for W. Problems with LOCATE() and QLOCATE()

8. Pdx for W. Problem with methods LOCATE() and QLOCATE()

9. Pdox 4.5 'Record | Locate | Value' vs. objectPal tcursor.locate()

10. Duplicate PDoxWin 5 TCursor function?

11. What to do if you liked TCursors???

12. tCursor problem


 
Powered by phpBB® Forum Software