Building data base aps with Rev

Rob Cozens rcozens at pon.net
Sat May 17 10:18:00 EDT 2003


Hi Sadu,

>I think it should be possible to write some kind of generic function
>to populate a screen (card) for one record in the data base.  Meaning,
>if you have a card that has a field for each corresponding field in
>a data base table (card field number matches data base field number),
>then this function would loop through all the fields, query the data
>base and populate the fields.  Or maybe there is an easier way.

The basic generic mechanism you describe was set forth for the 
HyperCard List by Serge Grenier's post, "Networking HyperCard Stacks" 
at least 8 years ago.  It is a workable solution.

With RunRev and MC, you have the option of using an SQL or Valentina 
db instead of a database stack.

>
>Basically it's the kind of code you'd have to write over and over if
>there is not a tool for it or some generic routines to call.  For
>example, with Unify's NXj, let's say I want an html screen for an
>Oracle table, I can just click a button for "build default screen
>form" and bingo, it's all coded for me in Java and jsp pages.

Yes, it is stack-specific code; so I designed Serendipity 
Database--Binary as a generic, reusable database stack.  An SDB 
record card has three fields: Record Type, Record Key, & Record 
Contents.  Individual fields are delimited items in the Record 
Contents field.

The SDB update I'm presently working on includes a data dictionary 
record type which (a) makes it possible to resolve dictionary 
references (ie: [Record Type]|[Data Name]) to "item x of 
recordTypeBuffer" for field storage & retrieval, and (b) establishes 
field input editing criteria (eg: alpha-only, digits-only, 
numbers-only, required?, secure?, decimal precision, special 
formatting, etc.) which can be used to edit & validate user input.

With a data dictionary in place, it is possible to build an input 
screen on-the-fly, with a card field for each record field and a 
title field or icon for each, and at one point I considered doing so; 
however, it's so easy to place new controls on a card from the 
menubar that I'm putting off automatic window generation, for the 
short term at least.

One of my unfinished HyperCard projects made an attempt at basic 
window generation:

* Selecting "New Record Type" would create a basic card with (in HC) 
20 bg fields & 20 card fields in pairs.  The bg fields were label 
fields & only accessible as such.  The card fields were data fields. 
The menubar let the developer toggle between title fields & input 
fields.  The "File Record" logic went something like:

on fileRecord recordType
   put recordType&&(card field 1)&return into recordTypeBuffer -- field 1 = key
   repeat with x = 2 to the number of card fields
     put (card field x)&"|" after recordTypeBuffer -- "|" is the fieldDelim char
   end repeat
   fileSDBRecord recordTypeBuffer
   checkSDBResult (the result)
end fileRecord

Conversely, to load a record:

on loadRecord recordType,recordKey
    put recordType&&recordKey into recordTypeBuffer
    getSDBRecord recordTypeBuffer
    checkSDBResult (the result)
    if word 1 of the result then exit loadRecord
    put word 2 to -1 of line 1 of recordTypeBuffer into card field 1 -- the key
    set the itemDelimiter to "|"
    repeat with x = 2 to the number of items in recordTypeBuffer
      put item x of recordTypeBuffer into card field x
    end repeat
end loadRecord

Hope this helps.  If you'd like to get into this in greater detail, 
check out the (pre-data dictionary) Serendipity Library at 
http://www.oenolog.com/ftp/serendipity_downloader.htm or contact me 
off-list.
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list