RosettaCodeData/Task/Abbreviations-simple/Yabasic/abbreviations-simple.basic
2023-07-01 13:44:08 -04:00

49 lines
1.4 KiB
Text

c$ = "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3"
c$ = c$ + " compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate"
c$ = c$ + " 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2"
c$ = c$ + " forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load"
c$ = c$ + " locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2"
c$ = c$ + " msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3"
c$ = c$ + " refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left"
c$ = c$ + " 2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1"
c$ = upper$(c$)
dim chunk$(1)
n = token(c$, chunk$())
dim lonc(n)
for i = 1 to n - 1
v = val(chunk$(i + 1))
if v then
lonc(i) = v
chunk$(i + 1) = ""
else
lonc(i) = len(chunk$(i))
end if
next
inp$ = "riG rePEAT copies put mo rest types fup. 6 poweRin"
inp$ = upper$(inp$)
dim w$(1)
x = token(inp$, w$())
dim lonw(x)
for i = 1 to x : lonw(i) = len(w$(i)) : next
for j = 1 to x
p$ = ""
for i = 1 to n
lc$ = left$(chunk$(i), lonw(j)) : lw$ = w$(j)
if (lw$ = lc$) and (lonc(i) <= lonw(j)) p$ = chunk$(i) : break
next
if p$ = "" p$ = "*error*"
r$ = r$ + " " + p$
next
print r$