Abbreviations, simple: Difference between revisions
→{{header|REXX}}: ooRexx conformance and readabie
m (→{{header|Wren}}: Minor tidy) |
Walterpachl (talk | contribs) (→{{header|REXX}}: ooRexx conformance and readabie) |
||
Line 3,837:
=={{header|REXX}}==
<syntaxhighlight lang="rexx">/*REXX program validates a user "word" against a "command table" with abbreviations.*/
'compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate',
'3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2',
'forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load',
'locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2',
'msg next 1 overlay 1
'refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left',
'2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1'
/*--------------------------------------------------------------------------------------*/
validate: Procedure Expose keyws
keyws=translate(keyws)
$= /*initialize the return string to null.*/▼
Arg userwords
res=''
Do j=1 to words(userwords)
uword=word(userwords,j)
Do k=1 to words(keyws) /* loop over keywords
kw=word(keyws,k)
L=word(keyws,k+1)
If
k=k + 1
Else
L=length(kw) /* it can't be abbreviated. */
If abbrev(kw,uword,L) Then Do /* is valid abbreviation */
Iterate j /* proceed with next userword */
End
End
res=res '*error*' /*processed the whole list, not valid */
End
Return strip(res) /* elide superfluous leading blank. */
</syntaxhighlight>
{{out|output|text= when using the default input:}}
<pre>
|