Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
AmigaDOS
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Scripting== AmigaDOS also has the feature of dealing with [[Batch file|batch]] programming, which it calls "script" programming, and has a number of commands such as <syntaxhighlight lang="doscon" inline>Echo</syntaxhighlight>, <syntaxhighlight lang="doscon" inline>If</syntaxhighlight>, <syntaxhighlight lang="doscon" inline>Then</syntaxhighlight>, <syntaxhighlight lang="doscon" inline>EndIf</syntaxhighlight>, <syntaxhighlight lang="doscon" inline>Val</syntaxhighlight>, and <syntaxhighlight lang="doscon" inline>Skip</syntaxhighlight> to deal with structured script programming. Scripts are text-based files and can be created with AmigaDOS's internal text editor program, called '''Ed''' (unrelated to Unix's [[Ed (text editor)|Ed]]), or with any other third-party text editor. To invoke a script program, AmigaDOS uses the command <syntaxhighlight lang="doscon" inline>Execute</syntaxhighlight>. <syntaxhighlight lang="doscon"> 1> Execute myscript </syntaxhighlight> This executes the script called "myscript". This method of executing scripts keeps the console window busy until the script has finished its scheduled job. Users cannot interact with the console window until the script ends or until they interrupt it. While: <syntaxhighlight lang="doscon"> 1> Run Execute myscript </syntaxhighlight> The AmigaDOS command <syntaxhighlight lang="doscon" inline>Run</syntaxhighlight> executes any DOS command or any kind of program and keeps the console free for further input. ===Protection bits=== Protection bits are flags that files, links and directories have in the filesystem. To change them one can either use the command '''Protect''', or use the '''Information''' entry from the '''Icons''' menu in Workbench on selected files. AmigaDOS supports the following set of protection bits (abbreviated as HSPARWED): *H = Hold (reentrant commands with the P-bit set will automatically become resident on first execution. Requires E, P and R bits set to work. Does ''not'' mean "Hide". See below.) *S = Script (Batch file. Requires E and R bits set to work.) If this protection bit is set on, then AmigaDOS is able to recognize and automatically run a script by simply invoking its name. Without S bit scripts can still be launched using the <syntaxhighlight lang="doscon" inline>Execute</syntaxhighlight> command. *P = Pure (indicates reentrant commands that can be made resident in RAM and then no longer need to be loaded any time from [[flash drives]], [[hard disks]] or any other media device. Requires E and R bits set to work.) *A = Archive (Archived bit, used by various backup programs to indicate that a file has been backed up) *R = Read (Permission to read the file, link or content of directory) *W = Write (Permission to write the file, link or inside a directory) *E = Execute (Permission to execute the file or enter the directory. All commands need this bit set, or they won't run. Requires R bit set to work.) *D = Delete (Permission to delete the file, link or directory) The H-bit has often been misunderstood to mean "Hide". In [[Smart File System]] (SFS) files and directories with H-bit set are hidden from the system. It is still possible access hidden files but they don't appear in any directory listings. Demonstration of H-bit in action: <syntaxhighlight lang="doscon"> AmigaPrompt> which list Workbench:C/List AmigaPrompt> list workbench:c/list Directory "workbench:c" on Thursday 30-Oct-08 list 6464 --p-rwed 25-Feb-02 22:30:00 1 file - 14 blocks used AmigaPrompt> which list Workbench:C/List AmigaPrompt> protect workbench:c/list +h AmigaPrompt> which list Workbench:C/List AmigaPrompt> list workbench:c/list Directory "workbench:c" on Thursday 30-Oct-08 list 6464 h-p-rwed 25-Feb-02 22:30:00 1 file - 14 blocks used AmigaPrompt> which list RES list </syntaxhighlight> :Notice how the '''list''' command becomes resident after execution when the H-bit is set. ===Local and global variables=== As any other DOS, Amiga deals with [[Variable (computer science)|environment variables]] as used in batch programming. 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. Global 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. The examples below demonstrate simple usage: <syntaxhighlight lang="doscon"> 1> setenv foo blapp 1> echo $foo blapp 1> set foo bar 1> echo $foo bar 1> getenv foo blapp 1> get foo bar 1> type ENV:foo blapp 1> setenv save foo $foo 1> type ENV:foo bar 1> type ENVARC:foo bar </syntaxhighlight> : If the <syntaxhighlight lang="doscon" inline>save</syntaxhighlight> flag of the <syntaxhighlight lang="doscon" inline>SetEnv</syntaxhighlight> command is set, this variable is saved permanently in <syntaxhighlight lang="doscon" inline>ENVARC:</syntaxhighlight> and remains available even after the current session has ended or the system has been restarted. Global variables are kept as files in '''ENV:''', and optionally saved on disk in '''ENVARC:''' to survive reboot and [[power cycling]]. '''ENV:''' is by default an assign to RAM:Env, and ENVARC: is an assign to '''SYS:Prefs/Env-archive''' where SYS: refers to the [[Booting#Boot_device|boot device]]. On bootup, the content of ENVARC: is copied to ENV: for accessibility. When programming AmigaDOS scripts, one must keep in mind that global variables are system-wide. All script-internal variables shall be set using local variables, or one risks conflicts over global variables between scripts. Also, global variables require filesystem access, which typically makes them slower to access than local variables. Since ENVARC: is also used to store other system settings than just string variables (such as system settings, default icons and more), it tends to grow large over time, and copying everything over to ENV: located on RAM disk becomes expensive. This has led to alternative ways to set up ENV: by using dedicated [[ramdisk]] handlers that only copy files over from ENVARC: when the files are requested. Examples of such handlers are <ref>{{cite web|url=http://aminet.net/package/disk/misc/HappyENV |title=disk/misc/HappyENV.lha |publisher=Aminet |access-date=2016-07-15}}</ref> and.<ref>{{cite web|url=http://aminet.net/package/util/sys/envhandler |title=util/sys/envhandler.lha |publisher=Aminet |access-date=2016-07-15}}</ref> An example demonstrating creative abuse of global variables as well as '''Lab''' and '''Skip''' is the AmigaDOS variant of the infamous [[GOTO]].<ref>{{cite web|url=http://www.safalra.com/programming/amigados/universal-register-machine/|title=Code by Stephen Morley|access-date=April 5, 2016}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)