The Abbrev function determines whether one string info is a leading substring of another string information. An optional minimum length can be specified. The function returns 1 when the test string is a leading abbreviation of the reference string, and 0 otherwise. If the test string is shorter than the minimal length, then 0 is returned.
result = Abbrev( information, info [, length ] ] ) |
Please observe:
say 'Do you want to use the force (but only when necessary) ?' inputValue = linein() if abbrev( 'PERFORCE', inputValue ) then say 'The force is with you !' |
The above will show the forceful message when inputValue is the empty string. This error is corrected as follows:
say 'Do you want to use the force (but only when necessary) ?' inputValue = linein() if abbrev( 'PERFORCE', inputValue, 1 ) then say 'The force is with you !' else say 'Proceed carefully -- you lack the force...' |
Examples:
say Abbrev( 'Print', 'Pri' ) -- shows 1 -- 'Pri' is a leading substring of 'Print' say Abbrev( 'PRINT', 'Pri' ) -- shows 0 -- character case is incorrect say Abbrev( 'Print', 'Pr', 3 ) -- shows 0 -- 'Pr' is too short say Abbrev( 'Print', '' ) -- shows 1 -- the empty string is a leading substring of 'Print' !! say Abbrev( 'Print', '', 1 ) -- shows 0 -- the empty string is too short |