Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Paul Michael
  Where is Paul Michael?
 Shelton
 Connecticut - United States
 Paul Michael
 To: Simon Arnold
  Where is Simon Arnold?
 Halifax
 United Kingdom
 Simon Arnold
 Tags
Subject: RE: Syntax problem???
Thread ID: 21735 Message ID: 21787 # Views: 13 # Ratings: 0
Version: Visual FoxPro 5 Category: General VFP Topics
Date: Tuesday, April 01, 2003 6:41:59 PM         
   


> > > > > Hello All:
> > > > >
> > > > > I have a table I created (ref. POM3Z.DBF) that has 576 records. When I ship a package using the post office service I want to check the Zipcode the user enters, and the ARRAY for this field is 'sa_cust[8]'. I want to take this zip verify it against my table and verify what SACK# (ref. SCFCODE field) the package/envelope goes in.
> > > > >
> > > > > 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 diplay 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.
> > > > >
> > > > > Thank you,
> > > > >
> > > > > ERROR MSG:
> > > > > "Invaid subscript reference"

> > > > > and..
> > > > >
> > > > > "SQL: Statment is invalid"
> > > > >
> > > > > POM3Z.DBF Defs:
> > > > > zip |zipend |code |zone |scfcode |bmcnum |adccode
> > > > >
> > > > > Code:
> > > > >
> > > > > function GetSackNo
> > > > > lparameters a_cust[8] && zipcode field/array on the shipping screen that user inputs.
> > > > > select scfcode from POMB3Z.dbf ;
> > > > > where a_cust[8] between zip and zipend ;
> > > > > into array sa_cust[1] && numeric text field on the shipping screen to diplay sack#.
> > > > > if (_Tally > 0) && always return 1 for valid zipcodes
> > > > > return (.T.)
> > > > > endif
> > > > >
> > > > > endfunc
> > > >
> > > > You cannot define a parameter as an array, you need to change the function like so:
> > > >
> > > > FUNCTION GetSackNo
> > > > LPARAMETERS tcCust
> > > > 	LOCAL llRetVal
> > > > 	SELECT scfCode FROM POMB3Z ;
> > > > 		WHERE BETWEEN(tcCust,Zip,ZipEnd) ;
> > > > 		INTO ARRAY sa_cust
> > > > 	IF _TALLY > 0
> > > > 		llRetVal = .T.
> > > > 	ELSE
> > > > 		llRetVal = .F.
> > > > 	ENDIF
> > > > RETURN llRetVal
> > > > 

> > > >
> > > > Hope This Helps.
> > > > Simon Arnold.
> > > *************************************************************
> > >
> > > Hi Simon:
> > >
> > > Thank you for your quick response. I tried your code, received the samm error "SQL: Statment is invalid".
> > >
> > > I also tried this:
> > >
> > > FUNCTION GetSackNo
> > > LPARAMETERS tcZipCode
> > > LOCAL llRetVal
> > > SELECT scfCode FROM POMB3Z ;
> > > WHERE BETWEEN(tcZipCode,Zip,ZipEnd) ;
> > > INTO ARRAY sa_cust[1]
> > > IF _TALLY > 0
> > > llRetVal = .T.
> > > ELSE
> > > llRetVal = .F.
> > > ENDIF
> > > RETURN llRetVal
> > > endfunc
> > >
> >
> > What good does your WHERE clause do if your test value isn't in your database? I don't follow what you're trying to accomplish. Perhaps it would be more clear if we knew the structure of your POMB3Z.dbf file.
> >
> >
> > ---
> >
> > www.foxite.com - The Home of the Visual FoxPro Experts
>
> The INTO Clause of the SQL Select does not have to have the array dimensions on, as this will be created by the number of fields selected in the statement, so remove the [1] from the end of sa_cust.
>
> Simon Arnold.
******************************************

Good afternoon Simon, thanks again for your response. Tried what you suggested, no difference. No when I run debugger I clearly see my field array sc_cust[1], this is the array I need to stuff in my sack#.

Hello Michael:

You had ask form my table structure 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

Recall: For example: I ship a package to type in a zip 01023. Logic will check the pom3z.dbf to verify what the sak# is, for this it would be 010 (ref. SCFCODE field). Last the Sack number would be displayed on the processing screen (ref. the field/ARRAY that would diplay 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.


Thanks again gentalmen,
PM


COMPLETE THREAD

Syntax problem??? Posted by Paul Michael @ 3/31/2003 9:30:42 PM
RE: Syntax problem??? Posted by Simon Arnold @ 3/31/2003 10:11:38 PM
RE: Syntax problem??? Posted by Paul Michael @ 3/31/2003 10:34:02 PM
RE: Syntax problem??? Posted by Michael Gill @ 4/1/2003 12:46:11 AM
RE: Syntax problem??? Posted by Simon Arnold @ 4/1/2003 1:08:51 PM
RE: Syntax problem??? Posted by Paul Michael @ 4/1/2003 6:41:59 PM
RE: Syntax problem??? Posted by Paul Michael @ 4/1/2003 7:29:43 PM
RE: Syntax problem??? Posted by Michael Gill @ 4/1/2003 7:52:16 PM
RE: Syntax problem??? Posted by Paul Michael @ 4/1/2003 8:01:50 PM
RE: Syntax problem??? Posted by Paul Michael @ 4/1/2003 8:04:35 PM
RE: Syntax problem??? (UPDATE on problem) Posted by Paul Michael @ 4/2/2003 2:34:47 AM
RE: Syntax problem??? (UPDATE on problem) Posted by Jamie Osborn @ 4/2/2003 4:19:34 AM
RE: Syntax problem??? (UPDATE on problem) Posted by Paul Michael @ 4/2/2003 6:12:26 PM