[Vapp] Access properties using Perls Mac::Glue
Lloyd Butler
lbutler at on.pelmorex.com
Fri Jan 2 12:59:21 CST 2004
I am trying to make use of Vapp via Perl by using Applescript via Mac::Glue
under OS X.
I have the dictionary, and a simple working script, but I want to expand it
a bit, and I have hit a wall.
I want to replicate this routine to get the field names of the cursor:
tell application "Valentina Carbon"
set theDB to open file (thePath & theDatabase)
tell theDB
set theCursor to SQL Select theCommand
end tell
set fieldCount to count of field of record 1 of theCursor
set fieldNames to ""
repeat with x from 1 to fieldCount
set fieldNames to fieldNames & (name of field x of record 1 of
theCursor) & "|"
end repeat
end tell
in Perl and this is what I have so far:
# Let's create a database object to work with
$valObj = Mac::Glue->new('Valentina_Carbon') ;
$dbPath = $thePath.$theDatabase ;
$theDB = $valObj->obj(file => "$dbPath") ;
$theDB = $valObj->open($theDB) ;
if (! $theDB) {
return "Failed to open $dbPath : $MacError" ;
}
else {
$theCursor = $valObj->sql($theDB,select=>$theCommand) ;
$fieldCount = $valObj->count($theCursor,each=>"field") ;
for ($x=1; $x <= $fieldCount; $x++) {
####
## STUCK HERE IN GETTING THE FIELD NAMES FROM THE CURSOR
####
}
}
I have routines to query the data base and pull data out working just fine,
now I want to start to pull a few more properties from the cursor to help
format the data a bit.
In my Applescript routine I have a flag that allows me to cal the routine
and get the data returned as an html table with the field names at the top
of the table, as list of lists with the field names as the first element in
the list, or have the calling script define the format of the returned
results. I want to try and replicate the same thing in Perl so that I can
get my web pages running under Apache again.
Any ideas would be appreciated.
Lloyd Butler
More information about the Valentina
mailing list