Return values, Objects, Return values objects – Pinnacle Speakers DEKO500 User Manual

Page 129

Advertising
background image

Macro Programming Language

127

Deko500 User’s Guide

command girl

type "It’s a girl"

end

if $name == "Amy"

girl

elseif $name == "Meg"

girl

elseif $name == "Mickey"

boy

end

The subroutines “boy” and “girl” are local to this macro. When the macro ends, the
subroutines, like the variables, vanish.

R

ETURN

V

ALUES

The

return

command directs Deko500 to stop the current macro or subroutine and

return the value of its

expression

parameter to the macro that called it.

return [expression=]

For example, you might have a simple command called

test

that returns

1

if

successful, or

0

if not:

command test
if $name == "Amy"

return 1

else

return 0

end

The subroutine

test

can then be called from another macro:

$result = test
if $result == 1

type "It’s a girl"

end

Here are a few examples of Deko500 commands that return values:

$squareroot = sqrt 4.

sqrt

returns the real value

2.

$test = file_open

"

moon over miami

"

file_open

returns

1

if Deko500 successfully opens "moon over miami", or

2

if

not.

$color = rgb 0 0 100

The

rgb

command creates and returns a color object that is then assigned to the

variable

$color

.

O

BJECTS

An object is a data structure created by a command. Typical objects in Deko500
include colors, shaders, ellipses, rectangles, fonts and looks.

The elements of an object correspond exactly with the parameters of the command
that created it. Consider the

rgb

command, which creates a color:

Advertising