Change 17858 by pudge@pudge-mobile on 2002/09/08 04:47:02

        Save script context in compiled script
        From Bart Lateur

Affected files ...

.... //depot/maint-5.6/macperl/macos/lib/Mac/OSA/Simple.pm#4 edit

Differences ...

==== //depot/maint-5.6/macperl/macos/lib/Mac/OSA/Simple.pm#4 (text) ====
Index: macperl/macos/lib/Mac/OSA/Simple.pm
--- macperl/macos/lib/Mac/OSA/Simple.pm#3~16469~        Tue May  7 20:48:53 2002
+++ macperl/macos/lib/Mac/OSA/Simple.pm Sat Sep  7 21:47:02 2002
@@ -17,7 +17,7 @@
     load_osa_script %ScriptComponents);
 @EXPORT_OK = @Mac::OSA::EXPORT;
 %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
-$REVISION = '$Id: Simple.pm,v 1.3 2002/05/08 03:59:30 pudge Exp $';
+$REVISION = '$Id: Simple.pm,v 1.5 2002/09/05 23:41:51 pudge Exp $';
 $VERSION = '1.00';
 
 tie %ScriptComponents, 'Mac::OSA::Simple::Components';
@@ -175,7 +175,7 @@
     my($text, $comp, $script, $id);
     $self->{SCRIPT} = AECreateDesc('TEXT', $self->{SOURCE}) or
         _mydie() && return;
-    $self->{ID} = OSACompile($self->{COMP}, $self->{SCRIPT}, 0) or
+    $self->{ID} = OSACompile($self->{COMP}, $self->{SCRIPT}, 
+kOSAModeCompileIntoContext) or
         _mydie() && return;
     $self;
 }
@@ -259,11 +259,6 @@
 
 =head1 DESCRIPTION
 
-    **MAJOR CHANGE**
-    Scripting component in osa_script and compile_osa_script
-    is now the first parameter, not the second.
-    Now the script text is second.
-
 You can access scripting components via the tied hash
 C<%ScriptComponents> which is automatically exported.  Components are
 only opened if they have not been already, and are closed when the
@@ -379,6 +374,33 @@
 =back
 
 
+=head2 Script Context
+
+Scripts compiled by this module now compile scripts as
+I<script contexts>, which, in part, means they can maintain state
+information.  For example:
+
+       use Mac::OSA::Simple;
+       my $script = compile_applescript(<<'SCRIPT') or die $^E;
+       property foo: 20
+       set foo to foo + 1
+       SCRIPT
+       print $script->execute, "\n" for 0..2;
+
+Returns:
+       21
+       22
+       23
+
+Whereas in previous versions of this module, it would have returned:
+       21
+       21
+       21
+
+For a script that on disk, to maintain state information
+in the saved version, remember to call C<$script->save(LIST)>.
+
+
 =head1 TODO
 
 Work on error handling.  We don't want to die when a toolbox function
@@ -398,6 +420,11 @@
 =head1 HISTORY
 
 =over 4
+
+=item v1.01, Tuesday, January 22, 2002
+
+Save scripts as script contexts.  (Bart Lateur)
+
 
 =item v1.00, Tuesday, January 22, 2002
 
End of Patch.

Reply via email to