Page 1 of 1

jade scripting display methods

Posted: Sun Apr 18, 2010 5:19 pm
by shayne
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

Re: jade scripting display methods

Posted: Sun Apr 18, 2010 10:18 pm
by murray
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;

Re: jade scripting display methods

Posted: Mon Apr 19, 2010 4:13 am
by ghosttie
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;

Re: jade scripting display methods

Posted: Mon Apr 19, 2010 9:36 am
by BeeJay
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.

Re: jade scripting display methods

Posted: Mon Apr 19, 2010 4:47 pm
by shayne
Thanks for the help guys got it working now. :D