Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Operator/Operand type mismatch" - need help

Status
Not open for further replies.

PBREP

MIS
Mar 14, 2003
75
US
Hello Fox Guru's :<)

My problem is as follwed:

PURPOSE: I'm utilizing the POM3Z.DBF to look-up the sack# in reference to what the user Zip to is. What I want happen is my function to check the Zipcode that the user enters or from their consignee data (ARRAY for this field is 'sa_cust[8]'), from there my logic would verify what SACK# (ref. SCFCODE field) falls between the 'zip' & 'zipend' hence, the customer will know what sack/bin they can put their package/envelope goes in. The results from the sack# (ref. the sa_cust[1] array field) would be printed on a doc label. For now I need to capture the sack # on the processing screen.

> > For example: I ship a package to 01023, the Sack # would be 010 (ref. SCFCODE field). Last the Sack number would be displayed on the processing screen (ref. the field/ARRAY that would display data is the 'sa_cust[1] ').

!!! Keep in mind that this function is being intergrated to an existing software program written in (VFP 5.0); customizations such as fuctions are allowed through a prg file (cust_main.prg) and can be called several ways. !!!

QUESTIONS: Should my sa_cust be declared as a private or global variable ? Maybe it is updating from within my function. How do I pass a variable by reference ?
Is 'INTO ARRAY&quot; causing the problem?

Thank you,
PM

Table structure (POMBZ3.dbf)it is as followed:

ZIP char 5
ZIPEND char 5
CODE char 5
ZONE char 3
SCFCODE char 5
BMCNUM char 2
ADCCODE char 5

ATTEMPTS MADE:
* Tried a WHERE tcZipCode>=Zip and tcZipCode<=Zipend - made no difference.
* Tried under my Cus_INIT declare sa_cust[1] = &quot;&quot; - made no difference
* Tried changing your sa_cust[1] = arrRet to sa_cust[1] = arrRet[1] - made no difference
* Thought maybe the sa_cust array needs to be qualified with sc_ship.sa_ship - made no difference.

I get an error:
&quot;Operator/Operand type mismatch&quot;

If I run it through vf5 5.0 Debugger I get this error:

Error Message : &quot;Operator/Operand type mismatch&quot;
Line of code with error: &quot;SELECT scfCode FROM POMB3Z WHERE BETWEEN (tcZipCode,Zip,ZipEnd) INTO ARRAY arrRet&quot;


CODE:

FUNCTION GetSackNo(sc_ship.a_cus[8])
LPARAMETERS tcZipCode
LOCAL llRetVal
local array arrRet[1]
SELECT scfCode FROM POMB3Z ;
WHERE BETWEEN(tcZipCode,Zip,ZipEnd);
INTO ARRAY arrRet
IF _TALLY > 0
sa_cust[1] = arrRet
llRetVal = .T.
ELSE
sa_cust[1] = &quot;&quot;
llRetVal = .F.
ENDIF
RETURN llRetVal
endfunc

DID A TEST, THE RESULTS ARE AS FOLLWED:

Done this: sa_cust[1] = tcZipCode && Echo back
return

&quot;I GET 9999999999' in the array/field (Numeric base)&quot;
&quot;I GET XXXXXXXXXX' in the array/field (Charater base)&quot;

The array vaule is the same no matter if I add a Userdefine Charater or Userdefine Numer.

Done this: sa_cust[1] = &quot;hello&quot;

I GET &quot;HELLO&quot; in the aaray/field.
 
GOT IT TO WORK

SOLUTION:
Function call in the power act should be GetSackNo(sc_ship.a_cus[8]). whatever value is in sc_ship.a_cus(8) will be tcZipcode in the function.


the function should be :
FUNCTION GetSackNo (tcZipCode)

*LOCAL llRetVal && don;t need
local array arrRet[1]
SELECT scfCode FROM POMB3Z ;
WHERE BETWEEN(tcZipCode,Zip,ZipEnd);
INTO ARRAY arrRet
IF _TALLY > 0
sa_cust[1] = arrRet(1) && need array sunscript
*llRetVal = .T. && don;t need
ELSE
sa_cust[1] = &quot;&quot;
*llRetVal = .F. && don;t need
ENDIF
RETURN (.T.) don;t check the return value of the fucntion any code to change it is eroneous

endfunc
 
Since you're using FUNCTION GetSackNo(sc_ship.a_cus[8]) to pass the parameter (of which I'm having trouble figuring out what it is), this line would be out of place:
LPARAMETERS tcZipCode

Also, you will get that error if you are using the wrong data types in the query, such as
SELECT CharField FROM MyTable ;
WHERE CharField = NumericValue

Change your function to something like:

FUNCTION GetSackNo(tcZipCode)
LOCAL llRetVal
SELECT scfCode FROM POMB3Z ;
WHERE BETWEEN(tcZipCode,Zip,ZipEnd);
INTO ARRAY arrRet
IF _TALLY > 0
sa_cust[1] = arrRet
llRetVal = .T.
ELSE
sa_cust[1] = &quot;&quot;
llRetVal = .F.
ENDIF
RETURN llRetVal
Dave S.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top