Options

C/SIDE coding question

aztecconsultingaztecconsulting Member Posts: 55
With very little documentation I have been trying to figure out how to code reports in C/SIDE and for the most part I have gotten by but I am stumped on one issue:

The variable SSN is for the Social Security Number we added to our Staff table. I need to check each record and report if the SSN isn't valid because of bad formatting or alpha characters. (I can't change the form for various reasons.) Anyway, in VB Script I could just loop through each character in the SSN field and make sure the ASCII value of that character is valid for a number but I can't figure how to make that work in C/SIDE.

Anyone have any suggestions how I can get this work or a better way to validate the value in the field is all numeric?

Comments

  • Options
    PrebenRasmussenPrebenRasmussen Member Posts: 137
    If SSN fits inside an Integer or Decimal datatype I would recommend EVALUATE, otherwise you could use DELCHR and remove all numeric characters and then see if something is left.

    If SSN includes a checksum character then you can use STRCHECKSUM function.
  • Options
    fbfb Member Posts: 246
    Code and Text variables can be accessed one character at a time using array notation, like this:
    FOR i := 1 TO STRLEN(SSN) DO BEGIN
      IF (SSN[i] < '0') OR (SSN[i] > '9') THEN
        ERROR('SSN must contain digits only, please.');
    END;
    
  • Options
    krikikriki Member, Moderator Posts: 9,089
    An easier test is:
    IF DELCHR(SSN,'=','1234567890') <> '' THEN
      ERROR('SSN must contain digits only, please.');
    

    if also alfa can be used : use this:
    IF DELCHR(UPPERCASE(SSN),'=','1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ') <> '' THEN
      ERROR('SSN must contain digits only, please.');
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.