User Tools

Site Tools


at:tutorial:iat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
at:tutorial:iat [2007/04/19 22:29]
tvcutsem *
at:tutorial:iat [2012/06/09 13:50] (current)
elisag
Line 1: Line 1:
 ====== Interactive AmbientTalk ====== ====== Interactive AmbientTalk ======
 +
 +
 +===== Basic Usage =====
  
 The //interactive ambienttalk shell// (aka ''iat'') is the command-line interpreter of AmbientTalk. ''iat'' supports a very simple read-eval-print loop mode: you can type in expressions (currently only single-line expressions), evaluate them by pressing return and see the value of the expression, for example: The //interactive ambienttalk shell// (aka ''iat'') is the command-line interpreter of AmbientTalk. ''iat'' supports a very simple read-eval-print loop mode: you can type in expressions (currently only single-line expressions), evaluate them by pressing return and see the value of the expression, for example:
Line 7: Line 10:
 </code> </code>
  
-To start ''iat'', it suffices to execute it from the command-line, provided the ''java'' executable of a JDK1.3.3 or higher JVM is on your executable search path. To get an overview of all available options, execute:+To start ''iat'', it suffices to execute it from the command-line, provided the ''java'' executable of a JDK1.3.3 or higher JVM is on your executable search path. The shell script that starts ''iat'' works as follows: 
 + 
 +<code> 
 +iat [options] [file] [arguments] 
 +</code> 
 + 
 +Perhaps the most useful usage of ''iat'' is to start it with an AmbientTalk source file as argument, e.g.: 
 +<code> 
 +iat foo.at 
 +</code> 
 + 
 +This will make ''iat'' evaluate all of the contents of the file ''foo.at'' and print out the value of the last expression in the file. If ''-p'' was not specified on the command line, ''iat'' falls into a read-eval-print loop such that you can play around with the definitions loaded from the file. Any arguments following the filename are treated as arguments to the AmbientTalk program, not to ''iat''. They are accessible by evaluating ''system.getArgv()''
 + 
 +To get an overview of all available options, execute:
  
 <code> <code>
 iat --help iat --help
 </code> </code>
 +
 +<note>
 +An explanation of all the iat command line parameters is available [[http://code.google.com/p/ambienttalk/wiki/CommandLineParameters|here]].
 +</note>
 +
 +===== Shell Commands =====
 +
 +The AmbientTalk shell understands a limited number of "shell commands". All input starting with a colon (":") is treated by ''iat'' as a shell command. The following commands are supported:
 +  * '':q'' or '':quit'' => quit the interpreter.
 +  * '':l'' or '':load filepath'' => load a file (relative to the directory in which ''iat'' was invoked). The content of the file is evaluated as if the file was passed as argument to the shell during startup. The public definitions of the loaded file will be available at top-level.
 +
 +===== Input and Output =====
 +
 +The AmbientTalk shell enables very simple input and output operations by means of the top-level ''system'' object. Here is how to output text to the command-line:
 +
 +<code>
 +system.println("Hello world");
 +</code>
 +
 +Reading a line of text from the command-line is a bit less straightforward:
 +
 +<code>
 +system.readNextLine: { |line|
 +  system.println("I read: "+line)
 +} catch: { |ioException| /* ignored */ }
 +</code>
 +
 +The code between ''{'' and ''}'' basically serves as a callback function which will be invoked when the next line has been read. The reason for this callback-style read function is that AmbientTalk code may never be blocking. The rationale behind this execution model is explained later, in the [[actors|chapter on actors]].
 +
at/tutorial/iat.1177014576.txt.gz · Last modified: 2007/04/19 22:40 (external edit)