Welcome Guest (Log in)
Product Edition
Version
$
Basics
Expander triangle
Type
Keyword
Syntax

Introduced
1.0
Environment
Desktop,Server
Platform Support
Mac OS X,Windows,Linux
Security
None required
Summary
The character $ (dollar sign) is used to indicate an environment variable on Unix systems and a command-line parameter on Unix or Windows systems.
Examples

put $LOGNAME into field "Login Name"
if $0 is not myAppName then answer "Problem initializing!"

Additional Comments
Expander triangle

Use the $ keyword to interact with the system environment and to find out what arguments were used if the application was started up from the command line.

Comments:

The $ character marks two kinds of special variables: command-line arguments (on OS X, Unix, and Windows systems) and environment variables (on OS X and Unix systems).

If you start up the application from the command line (on OS X, Unix or Windows systems), the command name is stored in the global variable $0 and any arguments passed on the command line are stored in numbered variables starting with the $ character. For example, if you start the application by typing the following shell command:

myrevapp -h name

then the global variable $0 contains "myrevapp" (the name of the application), $1 contains "-h", and $2 contains "name".

If an argument includes spaces, it must be enclosed in quotes on the command line:

myrevapp -in "new info.txt" -out "new info.xml"

Gotcha: On Windows XP systems, individual arguments passed on the command line are placed in separate variables ($1, $2, and so on) only if they are quoted on the command line. Otherwise, all arguments are placed in the $1 variable.

On Unix and OS X systems, a variable whose name begins with the $ character is exported to the application's environment, and is inherited by processes started up by the shell function or the open process command. Use this technique to create your own environment variables.

You can access existing environment variables by prepending the $ character to the environment variable's name. For example, the following statement gets the contents of the LOGNAME environment variable:

get $LOGNAME

Lessons
Expander triangle
Lesson icon

Lots of applications and programs allow you to open them by dragging a file onto the application icon. The application will then open and load the file you dragged on.

It is quite simple to add this behavior to your Rev standalones. In this lesson we will show you how to create a standalone that displays a text file in a field when you drag a text file onto the standalone.

User Comments
Expander triangle
User thumbnail
Mark Wieder
StarStarStarStarStar
May 3, 2009
get $# will return the number of commandline arguments (including $0)
User thumbnail
david_beck@ministryschedulerpro.com
StarStarStarStarStar
Sep 9, 2009
On Windows you can open double-clicked files associated with standalone based on the command line arguments, but on Mac the path of the double-clicked file is not passed to the standalone in the command line arguements. Anybody know how to find the path of a double-clicked file on Mac so it can be opened by the standalone when it is double-clicked?
User thumbnail
david_beck@ministryschedulerpro.com
StarStarStarStarStar
Sep 9, 2009
Found answer to my own question. On Mac to launch a file assocated with a standalone when it is double clicked, you can do:


on appleEvent pClass, pID, pSender
if pClass is "aevt" and pID is "odoc" then
request appleEvent data
put it into theFiles ## files OS is requesting your application opens, one per line
if theFiles is not "not found" and theFiles is not empty then
## code to open theFiles
end if
else
pass appleEvent
end if
end appleEvent


(Trevor DeVore originally posted a similar solution on the use-rev list which is where I got this information. Thanks Trevor.)
User thumbnail
charlie@linuxdragon.net
StarStarStarStarStar
Oct 8, 2009
Exercise caution when using environment variables. Users can change them at runtime which can cause unexpected values. Depending on your implementation, this could open your app up to exploitation by malicious users.