jade scripting display methods

Forums for specific tips, techniques and example code
shayne
Posts: 2
Joined: Sun Apr 18, 2010 4:49 pm

jade scripting display methods

Postby shayne » Sun Apr 18, 2010 5:19 pm

Hi I am newbie to Jade

I am trying to write a jade script to display some of the details in a class I have created. So far this is all I have :oops: .

displayBooks();

vars
books : Books;
begin
beginTransaction;
write Books.firstInstance;
commitTransaction;
end;


Any help would be great Thanks

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: jade scripting display methods

Postby murray » Sun Apr 18, 2010 10:18 pm

It's not clear what your goals are, but here's a few pointers that may help.

1. You only need beginTransaction/CommitTransaction for persistent updates. They're not needed here.

2. You can invoke the Jade object inspector to interactively inspect objects: e.g. Books.firstInstance.inspect(), or books.firstInstance.inspectModal(), if you want.

3. You can list details of all objects in a collection with a 'foreach' loop (presuming Books is a collection of Book):

Code: Select all

foreach book in Books.firstInstance do write book.display; // display will list individual properties endforeach;
Murray (N.Z.)

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: jade scripting display methods

Postby ghosttie » Mon Apr 19, 2010 4:13 am

That's not quite right - firstInstance returns the first instance, not a collection of the instances. It should be something like this:

Code: Select all

foreach book in Books.instances do write book.display; // display will list individual properties endforeach;
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: jade scripting display methods

Postby BeeJay » Mon Apr 19, 2010 9:36 am

You may also want to refer to the online tutorial, at http://www.jade.co.nz/jade/education/gs/GS001.htm, as this takes you through creating your first Jade application.

Also, it would be more usual to call the class Book rather than Books as a single instance of the class would normally deal with only a single book.

Cheers,
BeeJay.

shayne
Posts: 2
Joined: Sun Apr 18, 2010 4:49 pm

Re: jade scripting display methods

Postby shayne » Mon Apr 19, 2010 4:47 pm

Thanks for the help guys got it working now. :D


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 8 guests

cron