[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference iosg::all-in-1_v30

Title:*OLD* ALL-IN-1 (tm) Support Conference
Notice:Closed - See Note 4331.l to move to IOSG::ALL-IN-1
Moderator:IOSG::PYE
Created:Thu Jan 30 1992
Last Modified:Tue Jan 23 1996
Last Successful Update:Fri Jun 06 1997
Number of topics:4343
Total number of notes:18308

1525.0. "Valid characters for a field" by WOTVAX::PC0302::Doran (Confuse-a-cat Ltd) Tue Sep 29 1992 13:03

I have an application in which I wish to validate some fields to ensure that 
certain characters have not been entered.

I do not want to use the MAKE_FILE_NAME function (as is used in places around 
ALL-IN-1) as this would invalidate spaces.

I am using the following code:-

;;~~VALID_TEXT~~;;

GET #VALID = OA$Y\
GET OA$FUNC = '.IF ' OA$FIELD_NAME ' CONTAINING "?" OR
 ' OA$FIELD_NAME ' CONTAINING ":" OR
 ' OA$FIELD_NAME ' CONTAINING "*" OR
 ' OA$FIELD_NAME ' CONTAINING "+" OR
 ' OA$FIELD_NAME ' CONTAINING "-" THEN GET #VALID = OA$N'\
.IF #VALID EQS OA$Y
 THEN OA$VAL_SET_VALID
 ELSE GET OA$DISPLAY = "You have entered invalid charcters"\\
      FORCE\\
      GET OA$FUNC = 'OA$FLD_STAY ' OA$FIELD_NAME

This code works fine as shown. The problem occurs in trying to work out the 
syntax for invalidating the single and double quotes (' and ").

I have tried:-

GET OA$FUNC = '.IF ' OA$FIELD_NAME ' CONTAINING "'''" THEN GET #VALID = OA$N'
GET OA$FUNC = ".IF " OA$FIELD_NAME " CONTAINING '"""' THEN GET #VALID = OA$N"

Neither seems correct (although no error message is given - the text for 
OA$DISPLAY is simply not displayed...)

What would the correct syntax be?

Cheers,

Andy


T.RTitleUserPersonal
Name
DateLines
1525.1IOSG::MAURICESee belowTue Sep 29 1992 14:0812
    Hi,
    
    Try:
    
GET OA$FUNC = '.IF ' OA$FIELD_NAME ' CONTAINING "''" THEN GET #VALID = OA$N'
GET OA$FUNC = ".IF " OA$FIELD_NAME " CONTAINING '""' THEN GET #VALID = OA$N"
    
    The principle is that you need to double the quote.
    
    Cheers
    
    Stuart
1525.2SolutionSCOTTC::MARSHALLDo you feel lucky?Tue Sep 29 1992 14:2648
Hi,

The best solution to your problem is, I think, to remove one level of quotation
marks: use OA$FIELD_TEXT instead of OA$FIELD_NAME, then you don't need the
GET OA$FUNC = stuff, so just have:

.IF OA$FIELD_TEXT CONTAINING "?" OR
 OA$FIELD_TEXT CONTAINING ":" OR
 OA$FIELD_TEXT CONTAINING "*" OR
 OA$FIELD_TEXT CONTAINING "+" OR
 OA$FIELD_TEXT CONTAINING "-" OR
 OA$FIELD_TEXT CONTAINING "'" OR
 OA$FIELD_TEXT CONTAINING '"' THEN GET #VALID = OA$N'\
.IF #VALID EQS OA$Y
 THEN OA$VAL_SET_VALID
 ELSE GET OA$DISPLAY = "You have entered invalid characters"\\
      FORCE\\
      GET OA$FUNC = 'OA$FLD_STAY ' OA$FIELD_NAME

You can simplify this even further, viz:

/VALID=<.IF OA$FIELD_TEXT <=> "?" OR OA$FIELD_TEXT <=> ":" OR
            OA$FIELD_TEXT <=> "*" OR OA$FIELD_TEXT <=> "+" OR
            OA$FIELD_TEXT <=> "-" OR OA$FIELD_TEXT <=> "'" OR
            OA$FIELD_TEXT <=> '"'
        THEN OA$VAL_SET_VALID
        ELSE GET OA$DISPLAY = "You have entered invalid characters"

You don't need the FORCE or OA$FLD_STAY.

And finally, to use the same validation code for lots of fields, use:

/VALID=<XOP "~~VALIDATE~~"

    :
    :
    :

;;~~VALIDATE~~;;

.IF OA$FIELD_TEXT ...
    ... THEN OA$VAL_SET_VALID ...
        ELSE GET OA$DISPLAY = "..."

ie you don't even need to OA$FLD_STAY stuff to do it this way.

Also note I haven't tested any of this, it's meant as suggestions/ideas
Scott