130 pts.
 CHECK vs SCAN
RPG
can anyone explain me when to use CHECK and SCAN and differentiate between them? Please provide examples too...thanks

Software/Hardware used:
ASKED: October 6, 2008  8:24 AM
UPDATED: October 10, 2008  2:11 PM

Answer Wiki:
Check confirms that every character in the factor two string is in the list in factor 1 Example 'ABCDEF' Check TestString If testString contained 'BBB' or 'BAC' it would pass-- every character are in the factor 1 val. If testString contained 'A123' or 'Fabcdef' it would fail and return the position 2 - where the first unacceptable character was found. Scan looks for an exact match' Example 'ABCDEF' Scan TestString If testString contained 'BBB' or 'BAC' it would fail If testString contained '123' or 'abcdef' it would fail. If testString contained '123ABCDEF456' it would pass and return the position 4 (where it's found)
Last Wiki Answer Submitted:  October 6, 2008  1:31 pm  by  philpl1jb   44,630 pts.
All Answer Wiki Contributors:  philpl1jb   44,630 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Hi Philip or anybody
thanks for your answer. But still i am confused by the example you have given and Factor1 and Factor2 and result. Can you please elaborate and excplain it clearly with a better example…

regards
Ram

 130 pts.

 

Check might be used to test a text string to determine if it’s a valid UPC number – (only digits)

ValidSTR = ’1234567890′
ValidSTR Check UPCSTR BadPos
if BadPos > 0
Exsr BadUPCSTR
Endif

Here the string UPCSTR is tested for any value other than the 10 digits
If UPCSTR = ’92AB569ZZ999′
then BadPos would contain the value 3 – the first position containing the character ‘A’
because that character wasn’t in the ValidSTR ‘

Newer function that does the same thing
BadPos = %CHECK( ValidSTR : UPCSTR)
———————————————————————-
Scan would be used in a text search situation like partial name

SearchStr = ‘BOB’

SearchStr SCAN FullNameStr
If %found
Exsr AddRecSFL
Endif

Found values would be ‘BOB BLAKE’, ‘JIM ROBOBD’, ‘SUE BOBBY BOOP’
Not Found values would be ‘Bob Blake’, ‘PHIL GORILLA’, ‘MAX SMITH’

Alternative format

PosFnd = %SCAN( SearchStr : FullNameStr)
If PosFnd > 0

or

If %SCAN( SearchStr : FullNameStr) > 0

 44,630 pts.