Your code resolves to ram:/file.txt which is not correct. The right path should be ram:file.txt.
Edit2: os4 contains some new shell commands which allow to connect and split file name components. I don't remember the names, but as they refer to the similar dos.library functions, they supposedly are addpart, filepart and pathpart.
Knowing that, your delete would probably be best like this:
set testfile `addpart $test file.txt` delete $testfile
What if the filepath contained in the env variable contains spaces? Where do I put the quote marks? Tried a few ways, none work.
EDIT: Anyone got any more tips I can add to my explanation of Environmental Variables? I have room for perhaps 2 more if you keep it short and sweet.
---
Environment variables are used in AmigaOS within script or batch script processing. There are both global and local variables, and they are referred to with a dollar sign in front of the variable name, for example $myvar. Global variables are available system-wide; local variables are only valid in the current shell. In case of name collision, local variables have precedence over global variables.\nGlobal variables can be set using the command SetEnv, while local variables can be set using the command Set. There are also the commands GetEnv and Get that can be used to print out global and local variables.
Global variables are kept as files in ENV:, and optionally saved on disk in ENVARC: to survive reboot and power cycling. ENVARC: is an assign to SYS:Prefs/Env-archive where SYS: refers to the boot device.
Tip: Surround a variable in curly braces {} to construct a filepath if you are going to use a command such as 'Delete'.
Edited by djrikki on 2012/2/7 18:51:49 Edited by djrikki on 2012/2/7 18:52:33
Use set instead of setenv and then use unset at the end of your scripts to tidy up.
Sometimes if your inserting a variable into a string that has an underscore you have to escape the underscore with a *. eg.
copy "CD0:VIDEO_TS/VTS_0$number*_1.VOB"
Sometimes you have to use a ' to escape characters.
If you want to have quotes round filenames in lists gernerated by the list command you need to escape them with *, this also works with the echo command. eg.
list dh0: all files pat "#?.info" lformat "delete *"%P%N*"" to ram:script
Also remember that because you use * as an escape character in the list command you cannot use it as a wildcard so pat *.info would not work in the above example.
Amiga user since 1985 AOS4, A-EON, IBrowse & Alinea Betatester
I understand you are working on a tutorial on using environmental variables. Why not have a look how Gui4Cli uses these. Not only can you of course use all the CLI commands you will describe, but here are few Gui4Cli plus - Under Gui4Cli when you name a variable .MyVar, this is an environmental variable, which will appear in env: as env:.MyVar
As for normal Gui4Cli variables you will be able to use constructs such as
YourVar = $.MyVar[0][5] (first 5 characters) YourVar = $.MyVar[-5] (last 5 characters) etc.l You can easily load the file env:.MyVar in a listview and manipulate the lines of a multiline environmental variable
You can also define a set of (normal or environmental) variables MyVar1, MyVar2, MyVar3 and get their values with i = 3 YourVar = $MyVar$i
Aye,each article is very short, its more of a knowledge-base than a tutorial so might have to divide environmental variables into two articles so I can cover as much as possible.
If you want to get an idea of how long an article can be simply download/use Jack and press F2 or click the boing-ball in the top-left. You can even submit your own articles to me if you feel so inclined- however I'd wait till the next version because its much bigger than the one in 2.9.1 which is unfinished.
The knowledge-base currently (yet to be released version) now has over 200 articles in it; you, me, anyone in the community can submit articles or any relevant subject matter for inclusion.
I am missing an article on portablE atm - so if ChrisH is reading this perhaps he can write me a passage or two as I am busy this evening and probably tomorrow as well with real work.