Register to post in forums, or Log in to your existing account
 

This forum is locked: you cannot post, reply to, or edit topics.  This topic is locked: you cannot edit posts or make replies.     Home » Forums » General zApp Discussion
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Aug 31, 2004 8:49 pm   

I'm luvin Zeus
 
Today I needed to write a test program to see if the new "Queue" object was basically working. Before I realized it, I had written the program in Zeus and was quickly doing my testing.

It took me a while to think about this...why did I write my test program in Zeus instead of Delphi? After all, the Queue object is a Delphi TzQueue class. Yes, it's also a <QUEUE> component in Zeus and an IzQueue COM interface. All I needed to do was test stuff like Push, Pop, Delete, etc to make sure that my linked-list implementation was working.

I've been programming in Delphi since v1.0 at least 10 years ago. I've been programming in Pascal even longer. But I wrote my test program in Zeus without even thinking about it.

I think this is a really good sign. Zeus is stable and easy to use. The more I use it, the more stuff gets tweaked to work even better.

Here is the little test program that I wrote:
Code:
<window>
  <queue name='Queue1'/>
  <toolbar>
    <item caption='Add'>Queue1.Add Edit1.Text</item>
    <item caption='Push'>Queue1.PushHead Edit1.Text</item>
    <item caption='Pop'>Queue1.PopHead</item>
    <item caption='Trim'>Queue1.PopTail</item>
    <item caption='Insert'>Queue1.Insert Grid.Row, Edit1.Text</item>
    <item caption='Delete'>Queue1.Remove Grid.Row</item>
    <item caption='Replace'>Queue1.Item(Grid.Row) = Edit1.Text</item>
    <item caption='Set'>Queue1.State(Grid.Row) = 1</item>
    <item caption='Reset'>Queue1.State(Grid.Row) = 0</item>
  </toolbar>
  <edit name='Edit1' align='top'/>
  <grid name='Grid' collection='Queue1' align='client' columns='state|value'/>
  <script>
    sub Grid_OnGetCellText( Sender, Param)
      if not(IsNull(Param.RowObj)) and (Param.Col = 0) then
        Param.Text = Queue1.State(Param.Row)
      end if
    end sub
  </script>
</window>

All I needed was a Queue object, and a visual way to test it. Well, the <GRID> component in Zeus is already set up to display Queues and Collections. Then I just needed a bunch of buttons to execute various test actions. So I threw in a toolbar.

The original test program was even simpler. The original Grid didn't have any columns so it just displayed the text in the queue. But then I wanted to test setting and retrieving the state from each item in the queue.

Here is where Zeus made this really easy. When a <GRID> is displaying a string Collection, the text from each row is just the text from the strings. Now, in Delphi if I was testing this I'd probably just use a TListBox (a Windows List control) to display the strings in the Collection. But how would I ever display the state of each item in the list? I would have to change the TListBox into some sort of TStringGrid and then do all of the work to display the extra column of information. As any Delphi programmer knows, the default TStringGrid in Delphi is far from easy to use by default, unless you have some left-over code from a previous project.

But in Zeus it's easy. The <GRID> component fires an event called OnGetCellText for each cell in the grid. This allows you to override the text in any cell. So, I check to see if the row object is valid (that's the string from the Collection) and if the column is zero, then I override the text with the state of that item in the queue.

So, in less than a minute, my single-column list of a collection became a 2-column grid with the queue state and queue text. And you can see how easy each of the testing buttons really is. The Grid.Row value indicating the current row number is 1-based just like Collections are. And you can see all of the formal stuff in the ZML file that I left out (like the <HEAD> and <SPLASH> and even the XML header)...Zeus still knows how to handle it.

So, instead of spending lots of time writing a test program in Delphi, I wrote it in Zeus and saved a lot of effort. I've used many development tools over the years, but writing a quick and dirty test app just using Notepad and running it with Zeus is a blast.

My analogy is using Notepad to write HTML pages. If you are doing really heavy-duty coding in PHP or some intricate table and form creations, then maybe you'd use something like Dreamweaver. But when you want a quick and dirty HTML page you just fire up Notepad, enter the raw HTML and you are done. We all do this. Zeus has that same feel. You don't have to go through the trouble of creating a whole new project, you just put some XML into a text file and run it.

Oh, and here is what the little test program looked like while I was running it:



It's even better looking that a quick and dirty test program in Delphi would have been. This is fun!
Reply with quote
Rainchild
Wizard


Joined: 10 Oct 2000
Posts: 1551
Location: Australia

PostPosted: Thu Sep 02, 2004 11:05 pm   
 
Maybe I'll find a use for Zeus after all, I often write up little applets in C++Builder to do a quick utility type of program that I use a couple of times then throw away. I guess if Zeus can access the Windows API's natively then I might use it to do them instead.

There's a neat little program: http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html which translates win32 api and structure declarations into multiple languages (eg C#, VB, Delphi, etc), I wonder if (one day) Zeus could do a similar type thing (if you were going to make Zeus into a more full programming language).
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Sep 03, 2004 1:17 am   
 
I doubt I'll do anything like direct access to the Windows API. Especially with the changes coming in Windows, I'm not sure that's a good thing, and it would be a pain in Zeus. Zeus works better with "objects" and none of the Windows API is object based. So, the best you will probably get is access via objects related to Delphi objects.

For example, for drawing graphical items in a window, Delphi has a "Canvas" object that encapsulates most of the Windows GDI. I'll certainly be providing a Zeus object like this. That will let you draw lines, rectangles, etc.

I'll take a look at the link that you gave to see what that's like. The Windows API is so huge, that unless there is an "automatic" way to make it all accessible via COM objects or something, then direct Windows API access is probably not going to happen.

Zeus is really intended for higher-level applications.
Reply with quote
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Home » Forums » General zApp Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2009 Zugg Software. Hosted on Wolfpaw.net