Abbreviations, easy: Difference between revisions
→{{header|REXX}}: ooRRexx conformance and readable
imported>RegalCode m (→{{header|R}}) |
Walterpachl (talk | contribs) (→{{header|REXX}}: ooRRexx conformance and readable) |
||
Line 3,218:
=={{header|REXX}}==
<syntaxhighlight lang="rexx">/*REXX program validates
userwords= 'riG rePEAT copies put mo rest types fup. 6 poweRin'
'COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find'
'NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput'
'Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO'
'MErge MOve MODify MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT'
'READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT'
'RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up'
Say 'full words: ' validate(userwords) /*display the result(s) To the terminal*/
/*----------------------------------------------------------------------------------*/
validate: Procedure Expose keyws
res=''
Do j=1 To words(userwords) /* loop through userwords
uword=word(userwords,j) /* get next userword
Do k=1 To words(keyws) /* loop through all keywords */
L=verify(_, 'abcdefghijklmnopqrstuvwxyz', "M") /*maybe get abbrev's len.*/▼
keyw=word(keyws,k)
▲
If L==0 Then
L=length(keyw)
L=L-1
If abbrev(translate(keyw),uword,L) Then Do /* uword is an abbreviation */
res=res keyw /* add the matching keyword To the result string */
iterate j /* and proceed with the next userword if any */
End
End
res=res '*error*' /* no match found. indicate error */
End
Return strip(res) /* get rid of leading böank */
syntaxhighlight>
{{out|output|text= when using the default input:}}
<pre>
|