View Single Post
Old 24 February 2018, 19:15   #9
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Quote:
Originally Posted by Sinphaltimus View Post
Thanks kolla, I'm sure I'll need to know that at some point. Akira's answer pretty much nailed it.


Let me come with a small update - as I wrote the previous, I was puzzling over what trick I would use to check if a variable is not set - and now it just dawned upon me

Code:
lab ask
unset answer
echo noline "What is your name? "
set >NIL: answer ?
if "$answer" eq "*$answer"
  echo "Sorry, I demand an answer!"
  skip back ask
else
  echo "Hello $answer"
endif
See that trick? Unlike "sensible" shells of other operating systems, Amiga shell will treat unset variables as literal strings, including the dollar sign. So the solution is of course to check if "$var" is the same as "*$var", where the latter is the actual string with the dollar sign explicitly escaped (using *).

So now you can go ahead and call yourself _x or whatever you like
kolla is offline  
 
Page generated in 0.04420 seconds with 11 queries