We help IT Professionals succeed at work.

VFP 6 (Visual Foxpro 6) Error

cafulford
cafulford asked
on
Hi, I am trying to figure out what the correct syntax is to fix the error in the attached .jpg. I am using VFP6.

Thanks in advance,

Charlie VFP6 Error
Comment
Watch Question

Olaf DoschkeSoftware Developer

Commented:
You give the reason yourself: product.case_qty is a numeric field. You can't use alltrim() - which is a string function - on a numeric value.

While an N(5) field stores it's numeric values in string format in the dbf file, it is converted to numeric (double) in memory, so your if found() else endif is setting HoldThisSAPCaseQty to a numeric value in the if case and the string "FNF" in the else case.

You would need STR(product.case_qty) to make HoldThisSAPCaseQty a string in both cases.

Bye, Olaf.

Author

Commented:
Hi Olaf,

I was only trying to convert it to a string because I was not sure how to get it embedded in:
strLbl = strLbl + "^FO25,65^BY.33^B3N,N,30,N,N^FD" + AllTrim(HoldThisSAPCaseQty) + AllTrim(label.cust_prod) + "^FS" + CRLF

What is the syntax for adding that field into the statement if I want to keep it numeric?

Thanks,

Charlie
Software Developer
Commented:
You can't keep it numeric, as you want to add it into a string.
And Alltrim() does NOT convert to a string, it just trims a string, STR() converts to a string.

All I was already saying is you need to make this correction:

If Found()
   HoldThisSAPCaseQty = STR(product.case_qty)
Else
   HoldThisSAPCaseQty = "FNF"
Endif

I hope this makes it clearer.

Bye, Olaf.
You have to convert it to the string otherwise you cannot embed it into the string.

Simply do what Olaf suggested or use TRANSFORM function:

HoldThisSAPCaseQty = TRANSFORM(product.case_qty)

on appropriate place.