Tutorial for Revolution

-= JB =- sundown at pacifier.com
Sat Jan 12 05:25:25 CST 2008


I see on open card Valentina init should have been made.

-=>JB<=-

below is the card script:
++++++++++++++++++++++++++++++++++++++++++++++

local mDatabase
--local mTable
local mPerson
local mName
local mLName
local mBirthDate

on OpenCard
     get Valentina_Init( 10 * 1024 * 1024  )
     DatabaseCreate
end OpenCard

on CloseCard
   DatabaseClose
   get Valentina_ShutDown
end CloseCard

on DatabaseCreate
   put VDatabase_Constructor() into mDatabase

   -- Build db full path near to stack:
   get the effective filename of this stack
   set the itemDel to slash
   put the (item 1 to -2 of it) & slash & "Database1" into dbPath

   get VDatabase_Open( mDatabase, dbPath )

   if VDatabase_ErrNumber(mDatabase) is not "0" then
     get VDatabase_Create( mDatabase, dbPath, "kDscDatBlbInd" )
     CreateStructure
   end if

   put VDatabase_Table( mDatabase, "Person" ) into mPerson
   put VTable_Field( mPerson, "Name" )  into mName
   put VTable_Field( mPerson, "LName" )  into mLName
   put VTable_Field( mPerson, "BirthDate" )  into mBirthDate
end DatabaseCreate

on DatabaseClose
     get VDatabase_Close( mDatabase )
     put VDatabase_Destructor( mDatabase ) into mDatabase
end DatabaseClose

on CreateStructure
     put VDatabase_CreateTable(mDatabase, "Person") into pTable

     get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" )
     get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" )
     get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" )
end CreateStructure

function DoAdd
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     get VTable_SetBlank(tblPerson)
     get CollectPanes()
     get VTable_AddRecord(tblPerson)
end DoAdd

function DoUpdate
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     get CollectPanes()
     get VTable_UpdateRecord(tblPerson)
end DoUpdate

function DoDelete
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     get VTable_DeleteRecord(tblPerson)
     get PopulateFields()
end DoDelete

function CollectPanes
      put VDatabase_Table( mDatabase, "Person" ) into tblPerson

      put VTable_Field( tblPerson, "Name" )  into pName
      put VTable_Field( tblPerson, "LName" )  into pLName
      put VTable_Field( tblPerson, "BirthDate" )  into pBirthDate

     get VField_Value( pName, field efName )
     get VField_Value( pLName, field efLName )
     get VField_Value( pBirthDate, field efBirthDate )
end CollectPanes

function PopulateFields
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     put VTable_Field( tblPerson, "Name" )  into pName
     put VTable_Field( tblPerson, "LName" )  into pLName
     put VTable_Field( tblPerson, "BirthDate" )  into pBirthDate
     put VField_Value( pName ) into field efName
     put VField_Value( pLName ) into field efLName
     put VField_Value( pBirthDate ) into field efBirthDate
end PopulateFields

function DoFirst
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     get VTable_FirstRecord(tblPerson)
     get PopulateFields()
end DoFirst

function DoPrev
   put VDatabase_Table( mDatabase, "Person" ) into tblPerson
   get VTable_PrevRecord(tblPerson)
   get PopulateFields()
end DoPrev

function DoNext
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     get VTable_NextRecord(tblPerson)
     get PopulateFields()
end DoNext

function DoLast
     put VDatabase_Table( mDatabase, "Person" ) into tblPerson
     get VTable_LastRecord(tblPerson)
     get PopulateFields()
end DoLast


More information about the Valentina mailing list