Building data base aps with Rev (Jan Schenkel)

Sadhunathan Nadesan sadhu at castandcrew.com
Sun May 18 22:24:05 EDT 2003


| Gets me going?  Wow. Yes.   BIG TIME!  
| 
| Thank you Jan!  Can hardly wait to try it


As a follow up to Jan's excellent post, I tried it both ways she
suggested - using the query manager/ db pallet - no scripting, and,
everything scripted.  Both worked great and yep, I was asking for the
no coding required method but I think I like the scripting better,
more control over what you are doing.

So I thought I would post the entirety of a working stack script to
complete her example, (a teeny bit of which she left as an excercise to
the reader).  It's basically all Jan's code.  Note, this is a rather
primative example, it has just a few fields and two buttons, a next
and previous button.  I'm going to work on editing, searching etc next.
Anyone sees any improvements to suggest, love to hear it.


....... cut here ......stack script ...


global pConnectionID, tSQLQuery, tCursor, tColumnNames

on openStack
  global pConnectionID, tSQLQuery, tCursor, tColumnNames

  put revOpenDatabase("Postgresql","yourserver.com","yourdbname","yourname","yourpasswd") into pConnectionID
  put "select * from yourrecordtype" into tSQLQuery
  put revQueryDatabase(pConnectionID, tSQLQuery) into tCursor
  put revDatabaseColumnNames(tCursor) into tColumnNames
  revMoveToFirstRecord pConnectionID
  refreshScreen
end openStack


on closeStack
  global pConnectionID, tColumnNames

  revCloseDatabase pConnectionID
  repeat for each item tColumnName in tColumnNames
    if there is a field tColumnName then
      put empty into field tColumnName
    end if
  end repeat
end closeStack


on refreshScreen
  global tCursor, tColumnNames

  repeat for each item tColumnName in tColumnNames
    if there is a field tColumnName then
      put revDatabaseColumnNamed(tCursor, tColumnName)into field tColumnName
    end if
  end repeat
end refreshScreen


...... cut here ....  button script

# previous record button 
on mouseUp 
  global tCursor

  revMoveToPreviousRecord tCursor
  refreshScreen
end mouseUp

...... cut here ....  button script

# next record button 
on mouseUp 
  global tCursor

  revMoveToNextRecord tCursor
  refreshScreen
end mouseUp




Eeekk... no comments  .. I'll get flamed for that for sure!  :-)



More information about the use-livecode mailing list