FUNCTIONS

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
col Ar
Posts: 24
Joined: January 11th, 2019, 4:05 am

FUNCTIONS

Post by col Ar »

Dear members,
have defined the following function:

Code: Select all

{ check entry of alpha string variables }
function alphachk( string alphavar, alphlen, string tail );
  { alphavar: the actual string to be checked }
  { alphlen: length of first consecutive part for the field, e.g. A-G is 7 }
  { tail: the last characters in the valid string }
  
  alphaentry = alphabet[1:alphlen]; { string of acceptable values }
  alphaentry = concat( strip(alphaentry), strip(tail) );
  totlen = length( strip(alphaentry) );
  aok = 0; { aok = 0 - string is bad, aok = 1 - string is good }     
  alphsize = length( strip(alphavar) );

  if alphsize then   
    { check for "?" as only character }
    aok = (alphavar[1:1] = "?" & alphsize = 1);
    if !aok then     { if not a single "?", check string }
      aok = 1;       { now assume string is good until we know otherwise }
      i = 1;         { i is position in string of acceptable values }
      x = 1;         { x is position in input string }
      { loop while the string is still good and there are more letters }
      while aok & x <= alphsize do
        aok = pos( alphavar[x:1], alphaentry[i:totlen-i+1] );
        if aok then     { letter is acceptable }
          i = i + aok;  { increment i to position after letter in string of acceptable values }
          x = x + 1     { increment x to next letter in input string }
        endif;
      enddo;
    endif;
  endif;
  alphachk = (!aok);    { alphachk = 0 - if string is good, = 1 - if string is bad }
end;
However, when I compile it, I get the error below
"RROR: Invalid symbol name near line 389 in GLOBAL procedure
ERROR: Single variable - cannot have subscript (unexpected left parenthesis) near line 1 in V217 procedure
ERROR: Single variable - cannot have subscript (unexpected left parenthesis) near line 1 in V243 procedure"

In the GLOBAL, I have the following:
numeric totlen, aok, alphsize, xchild, nextmem, col, xwoman, line, xcrop, xfarmer, xplots, alphachk;

string wothresp, vcc;
string notalpha, alphabet, alphaentry;

Could someone help me debug this please?
Thanks
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: FUNCTIONS

Post by josh »

You have alphachk declared twice: once as a numeric variable and once as a function. Remove the numeric variable declaration of alphachk.
col Ar
Posts: 24
Joined: January 11th, 2019, 4:05 am

Re: FUNCTIONS

Post by col Ar »

When I do that, I get error in my function ERROR: Right parenthesis expected near line 389 in GLOBAL procedure yet the right parenthesis exists
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: FUNCTIONS

Post by josh »

I pasted your function into an empty CSPro program and it compiles fine for me once I remove the extra alphachk declaration and add declarations for i and x. Perhaps there is something else in your program outside the snippet you posted. From what you posted I don't know which line is 389 so it is difficult to tell what could be wrong.
col Ar
Posts: 24
Joined: January 11th, 2019, 4:05 am

Re: FUNCTIONS

Post by col Ar »

check mail, I sent the prog.
Post Reply