Hot to run AppleScript within my RB prog? 
Author Message
 Hot to run AppleScript within my RB prog?

Hi,
i know there is a way to run AppleScripts within my REALbasic program.
What i want to do is to load an iDisk (by opening an alias of it) and to
eject it.
But how does it work?
I have imported my compiles AppleScript applications into my project, but
how can i run them?
I didnt find anything about that in the language reference.
thx.
Ronja


Fri, 07 Nov 2003 00:31:26 GMT  
 Hot to run AppleScript within my RB prog?

Quote:

> Hi,
> i know there is a way to run AppleScripts within my REALbasic program.
> What i want to do is to load an iDisk (by opening an alias of it) and to
> eject it.
> But how does it work?
> I have imported my compiles AppleScript applications into my project, but
> how can i run them?
> I didnt find anything about that in the language reference.
> thx.
> Ronja

Use an AppleScript like a function or a method:

A simple script:

ShutDownTheComputer 'ShutDownTheComputer is the name of your script

A script with parameters:

SetVolume(3) 'A parameter can only be an integer or a string

A script with returned value:

dim nam as string
nam=GetStartupDiskName 'Same thing about returned value: Integer or string

A script with returned value and parameters:

dim snd as integer
snd=GetAndSetVolume(0)

(Should not be changed since RB 2.x...)



Fri, 07 Nov 2003 01:25:16 GMT  
 Hot to run AppleScript within my RB prog?

Quote:

> Hi,
> i know there is a way to run AppleScripts within my REALbasic program.
> What i want to do is to load an iDisk (by opening an alias of it) and to
> eject it.
> But how does it work?
> I have imported my compiles AppleScript applications into my project, but
> how can i run them?
> I didnt find anything about that in the language reference.
> thx.
> Ronja

Your RB program can call your AppleScripts as if they were methods or
functions. It's in the Developer's Guide.

But.. Why do you need to use an AppleScript to mount an alias' volume?
Try this instead:

  dim theAlias as folderitem
  theAlias = GetFolderItem("My iDisk Alias")

RB will automatically resolve the alias, mounting your iDisk in the
process. Assuming everything went well with AppleShare, theAlias will
now refer to your mounted iDisk volume.

As far as unmounting the iDisk (or any other volume), I just whipped
this up because I had too much coffee this morning (beware line wrap):

Sub Unmount(v as folderItem)

  Declare Function Eject Lib "InterfaceLib" (volName as Ptr, vRefNum as
Short) as Short // no Inline68K code available for this function

  Declare Function UnmountVol Lib "InterfaceLib" (volName as Ptr,
vRefNum as Short) as Short // no Inline68K code available for this
function

  dim name as memoryBlock
  dim err as integer
  if v <> nil and v.Parent = nil then
    name = newmemoryBlock(64)
    name.Pstring(0) = v.Name
    err = Eject(name,v.MacVRefNum)
    err = UnmountVol(name,v.MacvRefNum)
  end if
End Sub

HTH.

--
"In a world full of lies / That tug at the truth
 I'm taking no sides / Now I recognize you." -DS



Fri, 07 Nov 2003 03:04:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Start running an uncompiled AppleScript by RB app

2. Applescript/RB Question.

3. RB and AppleScript question again.

4. Question about RB and AppleScript

5. calling applescript from RB again

6. RB and AppleScript

7. Applescript/RB help

8. How do I run a python script from an applescript

9. MCL run applescript script

10. screen print from within prog?

11. ignoring the shebang line when invoking from within a linux c++ prog

12. Getting an application's name from within RB

 

 
Powered by phpBB® Forum Software