[APBeta] Scripting question
Paul Rodman
paul at ilanga.com
Sat Apr 18 14:50:56 PDT 2009
On Apr 18, 2009, at 02:35 PM, Michael Portuesi wrote:
> Does the AP scripting language allow one to create objects from
> within a script?
> The number of global variables in my charts script frightens me, as
> does the number of parameters I have to pass to each of the
> functions within the script. I'd like to create an object to hold
> all these values, or perhaps a hash table that will store this blob
> of information as a set of named attributes.
>
> Without these sorts of language tools, it becomes difficult to build
> any sort of large-scale scripts inside AstroPlanner. (I realize
> this is directed at the compiler vendor, not you, but I had to vent).
Yes, it does (V1 and V2 for that matter)
e.g.
class MyClass
dim property1 as integer
dim property2 as string
sub Constructor()
property1=77
property2="Sunset Strip"
function Squodge() as string
return str(property1) + " " + property2
end function
end class
sub main()
dim a as MyClass
a = new MyClass
print a.Squodge
end sub
and so on.
I use a lot of classes in the 10,000+ line framework which is
prepended to each script (See Script->Framework Reference).
Note that in 2.0b34 I introduced a Dictionary class that allows you to
set up a "hash table" for storing and retrieving stuff.
e.g.
dim d as new Dictionary
d.Value("Param1") = 77
d.Value(9912) = "Whatever"
if d.HasKey(9912) then print d.Value(9912)
If you'd like a copy of the Framework source code for ideas, I can
provide it via personal e-mail.
Paul R.
More information about the APBeta
mailing list