[APBeta] Scripting question
Jeff Young
jey at adobe.com
Sun Apr 19 12:29:37 PDT 2009
Excellent stuff, Robin. I had managed to get classes working, but wasn't aware of structures or dictionaries. I'll have to spend some time at the link you provided once I have some to spare.
Cheers,
-- Jeff.
> -----Original Message-----
> From: apbeta-bounces at lists.astroplanner.net [mailto:apbeta-bounces at lists.astroplanner.net] On Behalf Of
> RPEHLM
> Sent: Sunday, April 19, 2009 8:40 AM
> To: AstroPlanner Beta Testers
> Subject: Re: [APBeta] Scripting question
>
> Classes are really good for this sort of thing; use them a lot myself.
> Don't forget you can use the 'public' or 'private' prefix to control the
> scope (visibility) of stuff inside your class. It's certainly possible
> to build arrays of classes.
>
> Also useful are structures (can only be used inside a class or module); e.g.
>
> public structure Blah
> flag as boolean
> index as integer
> name as string*20
> end stucture
>
> Note the *20 for the string declaration. Strings in structures are
> fixed length and padded with ASCII 0, so Len() will always return 20 in
> this particular case. Due to the way structures are implemented in
> RealBasic they cannot contain any data types whose length can vary. For
> example 'a() as string' is out
>
> The new Dictionary class is really really useful. You can build a
> dictionary where the Value holds a structure, an array, or a class, or
> even an array of classes or structures (haven't tried OLEObjects yet!
> :-D). One interesting feature of dictionaries of structures is that
> dictionary.value(key) will return the first element of the structure.
> Not sure if this is a RealSoftware bug or feature though :)
>
> I have been trying to use enums. So far I can declare them but have not
> been able to use them.
>
> The SQL class offers a whole new world of data storage and retrival
> possibilities. I have only just started looking at this but it appears
> to be really amazing. One of the best features is the ability to create
> a database in memory; useful for short term storage.
>
> A useful resource for APScript are the RealBasic Language Reference
> (RBLR) and User Guides (RBUG). (<http://www.realsoftware.com/download>)
> and scroll down to the 'Individual Files' section. Your first stop
> should be the RBScript class section in the RBLR. You do have to employ
> some trial and error to find out what will and what won't work in a
> script. This is where the 'Check for Errors' button is really useful!
>
> Another useful new class is RegEx. Haven't used it much yet but it
> should make checking user input or analysing file content a lot easier.
>
> Hope this helps
> Robin
>
> Paul Rodman wrote:
> >
> > 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.
> >
> >
> > _______________________________________________
> > APBeta mailing list
> > APBeta at lists.astroplanner.net
> > http://lists.astroplanner.net/listinfo.cgi/apbeta-astroplanner.net
> >
> >
> _______________________________________________
> APBeta mailing list
> APBeta at lists.astroplanner.net
> http://lists.astroplanner.net/listinfo.cgi/apbeta-astroplanner.net
More information about the APBeta
mailing list