dbTalk Databases Forums  

Demo: Simple Db Program

comp.databases.object comp.databases.object


Discuss Demo: Simple Db Program in the comp.databases.object forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Neo
 
Posts: n/a

Default Demo: Simple Db Program - 12-29-2004 , 09:16 PM






The following script demos a simple db program. It creates two persons
and two gifts. It creates a variable which is assigned a person. Based
on the gender of the person referred by variable, another variable is
assigned a gift. The variables are things in the db.

// Create gender class and make it an item in main directory.
CREATE *.name=+gender & it.item~in = dir;

// Create persons john and mary.
CREATE *.name=+person & it.item~in = dir;
CREATE *.name=+john & it.cls=person & it.gender=+male;
CREATE *.name=+mary & it.cls=person & it.gender=+female;

// Create toy xbox.
CREATE *.name=+toy & it.item~in = dir;
CREATE *.name=+xbox & it.cls=toy;

// Create perfume Chanel #5.
CREATE *.name=+perfume & it.item~in = dir;
CREATE *.name=+chanel #5 & it.cls=perfume;

// Create variables personX and giftX.
CREATE *.name=+variable & it.item~in = dir;
CREATE *.name=+personX & it.cls=variable;
CREATE *.name=+giftX & it.cls=variable;

// Create verb which allows vars to referTo something.
CREATE *.name=+refersTo & it.cls=verb;
CREATE refersTo.vbType = cr;

// Make var personX referTo john.
CREATE personX.refersTo = john;

// Set giftX based on gender of thing referred by personX.
IF (EQUAL ((personX.refersTo=%).gender=%) male) T(CREATE giftX.refersTo
= xbox) E(CREATE giftX.refersTo = chanel #5);

// Show what giftX refersTo in msgbox.
// Shows xbox.
OUTPUT (giftX.refersTo=%);

// Delete what giftX refersTo.
DELETE giftX.refersTo=xbox;

// Change personX from john to mary.
UPDATE personX.refersTo = () > mary;

// Set giftX based on gender of thing referred by personX.
IF (EQUAL ((personX.refersTo=%).gender=%) male) T(CREATE giftX.refersTo
= xbox) E(CREATE giftX.refersTo = chanel #5);

// Show what giftX refersTo in msgbox.
// Shows Chanel #5.
OUTPUT (giftX.refersTo=%);

// Note: requires XDb2 v5.0.0


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.