[VAPP] working with Valentina via Perl

Lloyd Butler lbutler at on.pelmorex.com
Wed Jan 21 17:12:20 CST 2004


Ruslan,

I have installed and configured Mac::Glue for Perl under OS X and I have
generated the Valentina glue file, which will give Perl access to the
Applescript guts of Valentina.

I have a routine that queries the database and returns a cursor and then
formats the result to text.
Here is the main part of the code.

# Let's create a database object to work with
$valObj = Mac::Glue->new('Valentina_Carbon') ;

$theDB = $valObj->obj(file => "$dbPath") ;
$theDB = $valObj->open($theDB) ;

if (! $theDB) {
	return "Failed to open $dbPath : $MacError" ;
}
else {	
	$theCursor = $valObj->sql($theDB,select=>$theCommand) ;
	$recCount = $valObj->count($theCursor,each=>"record") ;
	$fieldCount = $valObj->count($theCursor,each=>"field") ;

	@theData = $valObj->format($theCursor,using => $theFormat ,from =>
1,to => $recCount) ;
	
	$valObj->delete($theCursor) ;
}
What I would like to do is figure out how to get at various properties of
the cursor, like field names.

To do it in AS, it would be

set aField to name of field 1 of record 1 of theCursor

Any ideas how to do this using the model in Perl? I am still trying to get
use to this sort of object model.

I orignally thought something along the lines of

$fieldName = $theCursor->record[0]->field[0]->name ;

Thanks,

Lloyd Butler
Product and System Development Supervisor
TWN Commercial Services




More information about the Valentina mailing list