NASutils Knowledge BaseUnofficialPolski

BASIC · lesson 5 of 30 · First stepsCut and join text

left$, right$ and mid$ cut a text, len measures it, instr finds a part and + joins two texts.

Programming on the NAS › BASIC in 30 lessons

05-text.yab Download 05-text.yab

file$ = "Holiday-2027.JPG"

print "length: ", len(file$)
print "first 7: ", left$(file$, 7)
print "last 3: ", right$(file$, 3)
print "from 9, four: ", mid$(file$, 9, 4)
print "small letters: ", lower$(file$)
print "the dash is at ", instr(file$, "-")
print "joined: ", left$(file$, 7) + ".txt"

Terminal

$ yabasic 05-text.yab
length: 16
first 7: Holiday
last 3: JPG
from 9, four: 2027
small letters: holiday-2027.jpg
the dash is at 8
joined: Holiday.txt

Exercise

Print the name of a file without its ending.