BeOS-native Scripting

BeOS native scripting Using BRexx Version 1.3.2 for BeOS.

based on hey and the hey documentation by Attila Mezei

Usage

Within BRexx, the syntax of BeOS-native scripting commands is: address <app|signature> "<verb> <specifier_1> <of <specifier_n>>* [to <value>] [with name=<value> [and name=<value>]*]" where <verb> : get|set|count|create|delete|getsuites|quit|save|load|execute|'what' <specifier> : <property_name> [ '['index']' | '['-reverse_index']' | '['fromvalue to tovalue']' | name | "name" ] <value> : "string" | <integer> | <float> | bool(value) | int8(value) | int16(value) | int32(value) | float(value) | double(value) | BPoint(x,y) | BRect(l,t,r,b) | rgb_color(r,g,b,a) | file(path)

The verb

The verbs send the following messages: Note that the verb is not case sensitive but the specifier names (e.g. "Frame", "Label"...) are. You can use 'what' constants directly, like
address "Application" "_ABR"
will open the about window of the application.

load and save are actually not scripting commands, they are standard BeOS messages. They are included for convenience. E.g. open a file in Application (the path can be relative or absolute):

address "Application" "load file(/boot/home/images/Be.jpg)"
or save it:
address "Application" 'save Window "Be.jpg"'

Whether the application does something with these messages is a different story.


The specifier

The specifier can be direct, index, reverse index, range or named. Reverse range is not supported. If you enter an index which consists of only digits, you can omit the square brackets:

address "Application" "get Window 0"

The value

It is easy to use the type names in front of the value:
address "Application" "set .... to BPoint(100,100)"
You can also use square brackets:
address "Application" "set .... to BPoint[100,100]"
If the value string contains only digits, it will be considered an int32. If it contains digits and a dot, a float type is assumed. "true" or "false" can also be used as bools.


Examples

For these examples you need to start the Network preferences application (the classic way to demo scripting ;-)

Get the suite of messages which the application can handle:

address "Network" "getsuites"
do i = 1 to result.0
   say result.name.i result.type.i result.i
end

This prints the BApplication and BHandler suites.

Get the name of the application

address "Network" "get Name"
say result

Open the about window of the application

address "Network" "_ABR"

Get a window of the application (actually a messenger for the window)

address "Network" "get Window [0]"
say result
or you can omit the square brackets when using an index:
address "Network" "get Window 0"
say result
or you can specify a window name:
address "Network" 'get Window Network'
say result

Get the suite of messages which the window can handle:

address "Network" 'getsuites of Window Network'
do i = 1 to result.0
   say result.name.i result.type.i result.i
end
for the description of suite/vnd.Be-window see the BeBook.

Get the title, frame or other properties of the window:

address "Network" 'get Title of Window Network'
say result

address "Network" 'get Frame of Window Network'
say result

Set the title, frame or other properties of the window:

address "Network" 'set Title of Window Network to "hey is great"'

Note that the above changes the name of the window, and so it is best to set it back to "Network", or else the following commands won't work.

address "Network" 'set Frame of Window Network to BRect(0,0,300,300)'
or
address "Network" 'set Frame of Window Network to BRect[0,0,300,300]'

(You will get an error for these last two, since the Network preferences window is not resizable. However, it works with NetPositive's windows).

Get the suite of messages which the view can handle:

address "Network" 'getsuites of View 0 of Window Network'
do i = 1 to result.0
   say result.name.i result.type.i result.i
end
For a description of suite/vnd.Be-view see the BeBook.

Get a view property:

As we get to more complicated commands, you should see them as samples only. Most of them do not work with later versions of BeOS, because the layout of of the Network prefs application has changed.

address "Network" 'get Frame of View 0 of Window Network'
say result

address "Network" 'get Hidden of View 0 of View 0 of Window Network'
say result

address "Network" 'get Label of View 5 of View 0 of Window Network'
say result

address "Network" 'get Value of View 0 of View 2 of View 0 of Window Network'
say result

address "Network" 'get Text of View 2 of View 2 of View 0 of Window Network'
say result

Set a view property:

address "Network" 'set Frame of View 0 of Window Network to BRect(0,0,100,400)'
address "Network" 'set Hidden of View 0 of View 0 of Window Network to true'
address "Network" 'set Label of View 5 of View 0 of Window Network to "Restart Something"'
address "Network" 'set Value of View 0 of View 2 of View 0 of Window Network to 1'
address "Network" 'set Text of View 2 of View 2 of View 0 of Window Network to "joe"'

Close a window in an application

address "Network" 'quit Window Network'

Quit an application

address "Network" "quit"