Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Missing operand (apparently)
Message
From
31/12/2006 15:42:01
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
 
To
31/12/2006 15:10:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01181122
Message ID:
01181129
Views:
9
>When I test this bit of code, I get a 'missing operand' error.
>I can't see it. Can you?
>
>
>Count to JanCount for Alltrim(Crimetype) = "B&E Garage" and Month(CrimeDate)= 1 ;
>or Alltrim(Crimetype)= "B&E Home" and Month(CrimeDate)= 1 ;
>or Alltrim(Crimetype)= "Home invasion" and Month(CrimeDate)= 1 ;
>or Alltrim(Crimetype)= "B&E Business" and Month(CrimeDate)= 1 ;
>or Alltrim(Crimetype)= "B&E Cabin" and Month(CrimeDate)= 1
>
When I expand your code as follows, it runs without error:
CREATE CURSOR Test ;
	( CrimeType C(20) ;
	, CrimeDate D )

SELECT Test

* Following section is exactly the same as Grady's sample:
Count to JanCount for Alltrim(Crimetype) = "B&E Garage" and Month(CrimeDate)= 1 ;
or Alltrim(Crimetype)= "B&E Home" and Month(CrimeDate)= 1 ;
or Alltrim(Crimetype)= "Home invasion" and Month(CrimeDate)= 1 ;
or Alltrim(Crimetype)= "B&E Business" and Month(CrimeDate)= 1 ;
or Alltrim(Crimetype)= "B&E Cabin" and Month(CrimeDate)= 1
* End of original sample section

?JanCount

USE IN Test
So, the answer is there is nothing wrong with that section of code. As an aside:

- your CrimeDate criterion is always the same, regardless of the value of CrimeType
- the INLIST() function is handy for this type of expression

So, it could be rewritten as
COUNT TO JanCount ;
  FOR INLIST( ALLTRIM( CrimeType ), "B&E Garage", "B&E Home", "Home invasion", "B&E Business", "B&E Cabin" ) ;
    AND MONTH( CrimeDate ) = 1
As for why you might be having a problem:

- Do you have a comment immediately preceding your code, that ends in a semicolon? This would cause the first line of your code to be continued as part of the comment e.g.
* This is a comment, the next comment line ends in a semicolon making the first line
* of "actual code" a "continuation" of this comment;
Count to JanCount for Alltrim(Crimetype) = "B&E Garage" and Month(CrimeDate)= 1 ;
or Alltrim(Crimetype)= "B&E Home" and Month(CrimeDate)= 1 ;
...
- Do you have any #DEFINEs set that may be changing the code at compile time?
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform