[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Send Data and Do Script, alternative IDE for MacPerl



Could someone show me an example of how to use MacPerl's "Send Data"
AppleScript command? MacPerl's AppleScript dictionary is not too
explicit on that matter. What is the 'input record'? How do you use it?
How do tell the command the name of the Perl script?

I have not managed to use the Do Script command with more than two
parameters: the Perl script's name and another parameter. How do you
pass more than two parameters to Do Script (.e.g, Do script {scriptname,
param1, param2, param3...)? Do you use Send Data? How?

For those of you who still shy from using the Mac Toolbox in MacPerl,
CrossBasic can be used to create MacPerl interfaces. Here is how I did
it:

- I wrote a script in AppleScript containing the following code:

on run param
 set lescript to "Macintosh HD:ParseAppleScript.pl"
 --set param to "2,3,chien"
 set deuxParams to {lescript, param}
 tell application "MacPerl"
  try
   Do Script deuxParams
 
   return result as string
  on error
   return "error" as string
  end try
 end tell
end run

- I created a CrossBasic project, dropped the AppleScript on it, created
my interface, and created a CrossBasic function called DoScript and
containing the following code:

dim argument as string
dim res as string
argument = field1.text + "," + field2.text + "," + field3.text
res = TestMacPerl2(argument)
Resultat.text = res

- I associated DoScript to a button in the interface.
 

Here is how the whole shebang works. Whenever the user clicks the
button, DoScript is run. The contents of field1, field2, and field3 are
then passed to TestMacPerl2, which in turn passes the data on to
ParseAppleScript.pl:

my ($var1, $var2, $var3);
my @tableau;

@tableau = split(',',shift);
 
$var1 = shift @tableau;
$var2 = shift @tableau;
$var3 = shift @tableau;

MacPerl::Reply(($var1 * $var2) . " " . $var3 . "s" . " arrived tonight
on the 5:30PM train.");

Finally, ParseAppleScript.pl returns the result to the CrossBasic
application which displays it in the "res" field.

Phew!

If anyone wants to suggest improvements of the above code, please do so.

Philippe de Rochambeau

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch