I dont understand why tou are using two scripts, and then deleting one of them after execution.
Simply bulid and import one script into your RB project, and only run it the one time.
When you save the script, save it in Applescript Editor as a run only script, this way no one can
open or edit the script, also when you build your completed RB app, the run only script will be
compiled into your app’s code, so no way anyone could access its contents.
The other problem with deleting one of the scripts, is that in a situation where you try to run the
\script a second time, you will get an error message because the script no longer exists, you dont
want to introduce potential problems like this into your app.
As stated previously either have a boolean property in your script, or in your RB project that retains a value
telling you that the script has been run, so that you do not run it a second time, I believe you can create
a property in RS IDE that works like an applescript property, that will retain its value between runs.
But please remember that the Applescript properties only retain values when yo are not re compiling them
each time you run your app in the RS IDE.
But I am sure you can design your RB app to only call the script once, and then forget about it.
This sort of script should do the job.
[code]property scriptHasBeenRun : false as boolean
on run {}
set myPassword to “123” & return as text
if scriptHasBeenRun is equal to false then
try
tell application “System Events” to keystroke myPassword
set scriptHasBeenRun to true as boolean
return scriptHasBeenRun as text
on error errorMessage number errorNumber
set scriptHasBeenRun to false as boolean
return “Error” & space & errorMessage & space & errorNumber as text
end try
else if scriptHasBeenRun is equal to true then
return scriptHasBeenRun as text
end if
end run[/code]
calling this Applescript in RB would be something like this.
[code]Dim Result as string
Result = YourScriptName
If Result = “true” then
//The script has been run so dont run it again
elseif Left(Result, 6) = “Error” then
//An error occured during the script execution so handle it
end if[/code]
The alternative is set up a boolean RB property in the RS IDE and do something like this
on run {myPassword}
set myPassword to myPassword as text
try
tell application "System Events" to keystroke myPassword
return "Completed" as text
on error errorMessage number errorNumber
return "Error" & space & errorMessage & space & errorNumber as text
end try
end run
The code to call the above in RB would be something like this.
[code]RB property as boolean = false
Dim Result as string
Dim myPassword = “123” as string
Result = YourScriptName (myPassword)
if Result = “Completed” then
//Reset your RB property to true
//The script has been run so dont call it again
elseif Left(Result, 6) = “Error” then
//An error occurred in the script execution so handle it
end if[/code]
You do not set up a property in RB like this, you have to click the add property tab in the RS code editor, and
add it to a RB Module with a global scope setting, I have only written it like above for example purpose, if my
memory serves me right I beleive that RB properties retain their value between runs, even in the RS development
enviroment, but you should check the RB documentation to confirm this, as I have not used RB for a long while.
Well I hope this might be of some help
Regards Mark