Going Crazy trying to learn Revolution, Applescript puzzle.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 30
- Joined: Sun Feb 28, 2010 9:52 pm
- Location: Miami, Florida
- Contact:
Going Crazy trying to learn Revolution, Applescript puzzle.
Know a few computer languages, trying to grasp RunRev's. It says it supports Applescript, and I can only find one simi-good example. Logically, this should work, it populates the fields, but no script action. I've tried lots of variations trying to resolve, this looks like the closest to working (my opinion), but NOT! Why not?
See attachment
What am I missing?
~David
------------------------------------------------------------------------------------------------------------
on myAppleScript
put fld "myIMName" on Card "AlarmSettings" into fld "myNewIMName" on Card "AlarmStatus"
replace " " with empty in fld "myNewIMName" on Card "AlarmStatus" -- Attempting to remove blank spaces from field.
put fld "myIMBuddy" on Card "AlarmSettings" into fld "myNewIMBuddy" on Card "AlarmStatus"
replace " " with empty in fld "myNewIMBuddy" on Card "AlarmStatus" -- Attempting to remove blank spaces from field.
-------------------------------------------------------------------------------
put "tell application" && quote & "iChat" & quote & " activate" & cr & \
"log in service" && quote & fld "myNewIMName" on card "AlarmStatus" & quote & cr & \
"set the status message to" && quote & "Status Message" & quote & cr & \
"send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"send " & quote & fld "myAlarmMessage" on Card "AlarmStatus" & quote & " to buddy " & quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr into tScript
do tScript as AppleScript
put tScript into fld "BigAppleScriptBox" on Card "AlarmStatus"
-------1----------2---------3---------4---------5---------6---------7---------8--------
end myAppleScript
See attachment
What am I missing?
~David
------------------------------------------------------------------------------------------------------------
on myAppleScript
put fld "myIMName" on Card "AlarmSettings" into fld "myNewIMName" on Card "AlarmStatus"
replace " " with empty in fld "myNewIMName" on Card "AlarmStatus" -- Attempting to remove blank spaces from field.
put fld "myIMBuddy" on Card "AlarmSettings" into fld "myNewIMBuddy" on Card "AlarmStatus"
replace " " with empty in fld "myNewIMBuddy" on Card "AlarmStatus" -- Attempting to remove blank spaces from field.
-------------------------------------------------------------------------------
put "tell application" && quote & "iChat" & quote & " activate" & cr & \
"log in service" && quote & fld "myNewIMName" on card "AlarmStatus" & quote & cr & \
"set the status message to" && quote & "Status Message" & quote & cr & \
"send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"send " & quote & fld "myAlarmMessage" on Card "AlarmStatus" & quote & " to buddy " & quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr into tScript
do tScript as AppleScript
put tScript into fld "BigAppleScriptBox" on Card "AlarmStatus"
-------1----------2---------3---------4---------5---------6---------7---------8--------
end myAppleScript
- Attachments
-
- It returns this in fld "BigAppleScriptBox" on Card "AlarmStatus", note the spaces after IMusername and iMbuddy name.
- Picture 4.png (14.36 KiB) Viewed 4209 times
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Going Crazy trying to learn Revolution, Applescript puzzle.
Your example shows a gap between the last non-white-space character in the Jabber address and the closing quote. Could that be related to the issue?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 30
- Joined: Sun Feb 28, 2010 9:52 pm
- Location: Miami, Florida
- Contact:
Re: Going Crazy trying to learn Revolution, Applescript puzzle.
Unsure. Have attempted to remove 'white spaces' from the fields. (IE REPLACE) Assumed the CR at the end of each line was required by runrev (due to passing script onto OS X for execution), but a return is needed in Applescript.. From what I can tell the user (me) needs to construct one long string (in my case tScript, as it was called in the example I attempted to follow).
This string contains the "Applescript" you which to run. And I have used basically this same script for years in many of my automation projects. So I know it works (on its own).
Once constructed I pass the script on to runrev using "do tScript as AppleScript", I ASSUME.
However once all is done, it doesn't seem to do anything... I can get runrev to execute a Applescript that has been compiled into an APP, which in turn runs a script... Round about way of doing it but it works, just adds a lot of support files I didn't want to add..
If I can get runrev to do this it cuts out a LOT...
~David
This string contains the "Applescript" you which to run. And I have used basically this same script for years in many of my automation projects. So I know it works (on its own).
Once constructed I pass the script on to runrev using "do tScript as AppleScript", I ASSUME.
However once all is done, it doesn't seem to do anything... I can get runrev to execute a Applescript that has been compiled into an APP, which in turn runs a script... Round about way of doing it but it works, just adds a lot of support files I didn't want to add..
If I can get runrev to do this it cuts out a LOT...
~David
-
- VIP Livecode Opensource Backer
- Posts: 4000
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Going Crazy trying to learn Revolution, Applescript puzzle.
Hi Redlance305,
I do quite some passing between applescript and RunRev. What I find hard is to construct all the applescript in runtime with all the quotes and stuff.
I then make an applescript with variable that are declared at the top of the applescript with the changing content of the variable e.g. url's and stuff. The main logic is in the applescript. I test this applescript in Script Debugger (preferably) or Script editor, to make shure it works.
I than put the working main part of the script into a field (just paste it). The variables are constructed in the script on the fly and then I append the main script in the script, which then is executed do xxx as applescript.
A lot less errorprone since a lot easier.
Mind you there are people here that use the 'merge' function to replace keywords in the applescript with the variables you want to insert. This is very elegant and efficient, but for my needs too much.
Actually applescript and Runrev work very well. No problem here once you have got it working. (see above)
an example
and the field appleScript2 contains the main code of the applescript:
here I put the file reference into the applescript variable theFile, I think you get the idea
regards
Bernd
I do quite some passing between applescript and RunRev. What I find hard is to construct all the applescript in runtime with all the quotes and stuff.
I then make an applescript with variable that are declared at the top of the applescript with the changing content of the variable e.g. url's and stuff. The main logic is in the applescript. I test this applescript in Script Debugger (preferably) or Script editor, to make shure it works.
I than put the working main part of the script into a field (just paste it). The variables are constructed in the script on the fly and then I append the main script in the script, which then is executed do xxx as applescript.
A lot less errorprone since a lot easier.
Mind you there are people here that use the 'merge' function to replace keywords in the applescript with the variables you want to insert. This is very elegant and efficient, but for my needs too much.
Actually applescript and Runrev work very well. No problem here once you have got it working. (see above)
an example
Code: Select all
put revMacFromUnixPath (localFilmPath) into localPathforAppleScript
put "Set theFile to " & quote & localPathforAppleScript & quote & return into varForApplescriptAnnotations
put field "appleScript2" after varForApplescriptAnnotations
do varForApplescriptAnnotations as applescript
put the result into fromAppleScriptAnnotations
Code: Select all
tell application "QuickTime Player"
open file theFile
set condition2 to ""
set Macher to ""
set cellType to ""
set condition1 to ""
set theAnnos to ""
tell movie 1
try
set condition2 to full text of annotation "Comment"
end try
try
set Macher to full text of annotation "Copyright"
end try
try
set cellType to full text of annotation "Author"
end try
try
set condition1 to full text of annotation "Producer"
end try
end tell
set theAnnos to theAnnos & Macher & ","
set theAnnos to theAnnos & cellType & ","
set theAnnos to theAnnos & condition1 & ","
set theAnnos to theAnnos & condition2
if (count of documents) = 1 then quit
end tell
return theAnnos
regards
Bernd
-
- Posts: 30
- Joined: Sun Feb 28, 2010 9:52 pm
- Location: Miami, Florida
- Contact:
Re: Going Crazy trying to learn Revolution, Applescript puzzle.
Found the white spaces, they were coming from the file read, was able to remove them. Still no Applescript action.
Below is the output being sent to "do tScript as AppleScript"
-------------- Output ------------
tell application "iChat" activate
log in service "david@chat.jabber.org"
set the status message to "Status Message"
send "5:39:32 PM 2/28/10" to buddy "xserve01@chat.jabber.org"
send " Zone5: In Alarm 5:39:34 PM" to buddy "xserve01@chat.jabber.org"
-----------------------------------
Using the following code (please note I am new to runrev, and learning as I go (push the limits of my language knowledge). Been coding in PHP for a few years, so I have no problem dealing with all the quotes. <smile>
--------------------------
on myAppleScript
put fld "myIMName" on Card "AlarmSettings" into fld "myNewIMName" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMName" on Card "AlarmStatus"
replace cr with "" in fld "myNewIMName" on Card "AlarmStatus"
put fld "myIMBuddy" on Card "AlarmSettings" into fld "myNewIMBuddy" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myAlarmMessage" on Card "AlarmStatus"
-------------------------------------------------------------------------------
put "tell application" && quote & "iChat" & quote & " activate" & cr & \
"log in service" && quote & fld "myNewIMName" on card "AlarmStatus" & quote & cr & \
"set the status message to" && quote & "Status Message" & quote & cr & \
"send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"send " & quote & fld "myAlarmMessage" on Card "AlarmStatus" & quote & " to buddy " & quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr into tScript
do tScript as AppleScript
put tScript into fld "BigAppleScriptBox" on Card "AlarmStatus"
-------1----------2---------3---------4---------5---------6---------7---------8--------
-- "send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
end myAppleScript
Below is the output being sent to "do tScript as AppleScript"
-------------- Output ------------
tell application "iChat" activate
log in service "david@chat.jabber.org"
set the status message to "Status Message"
send "5:39:32 PM 2/28/10" to buddy "xserve01@chat.jabber.org"
send " Zone5: In Alarm 5:39:34 PM" to buddy "xserve01@chat.jabber.org"
-----------------------------------
Using the following code (please note I am new to runrev, and learning as I go (push the limits of my language knowledge). Been coding in PHP for a few years, so I have no problem dealing with all the quotes. <smile>
--------------------------
on myAppleScript
put fld "myIMName" on Card "AlarmSettings" into fld "myNewIMName" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMName" on Card "AlarmStatus"
replace cr with "" in fld "myNewIMName" on Card "AlarmStatus"
put fld "myIMBuddy" on Card "AlarmSettings" into fld "myNewIMBuddy" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myAlarmMessage" on Card "AlarmStatus"
-------------------------------------------------------------------------------
put "tell application" && quote & "iChat" & quote & " activate" & cr & \
"log in service" && quote & fld "myNewIMName" on card "AlarmStatus" & quote & cr & \
"set the status message to" && quote & "Status Message" & quote & cr & \
"send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"send " & quote & fld "myAlarmMessage" on Card "AlarmStatus" & quote & " to buddy " & quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr into tScript
do tScript as AppleScript
put tScript into fld "BigAppleScriptBox" on Card "AlarmStatus"
-------1----------2---------3---------4---------5---------6---------7---------8--------
-- "send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
end myAppleScript
-
- Posts: 30
- Joined: Sun Feb 28, 2010 9:52 pm
- Location: Miami, Florida
- Contact:
Re: Going Crazy trying to learn Revolution, Applescript puzzle.
Got it!!! While trying to remove the white spaces (before my first post), I 'cleaned' up the code removing some important code. So it seems!
The code below works fine! The delays are important in Applescript, gives the OS/app enough time to open, login, etc. Plus I forgot the 'end tell' would more than likely work without it, by way risk it. - Thanks for pushing me on the white spaces!
NOW WE ARE COOKING!
Again, thanks for the help!
~David
on myAppleScript
put fld "myIMName" on Card "AlarmSettings" into fld "myNewIMName" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMName" on Card "AlarmStatus"
replace cr with "" in fld "myNewIMName" on Card "AlarmStatus"
put fld "myIMBuddy" on Card "AlarmSettings" into fld "myNewIMBuddy" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myAlarmMessage" on Card "AlarmStatus"
-------------------------------------------------------------------------------
put "tell application" && quote & "iChat" & quote & cr & \
"activate" & cr & \
"delay 3" & cr & \
"log in service" && quote & fld "myNewIMName" on card "AlarmStatus" & quote & cr & \
"delay 4" & cr & \
"set the status message to" && quote & "Status Message" & quote & cr & \
"send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"send " & quote & fld "myAlarmMessage" on Card "AlarmStatus" & quote & " to buddy " & quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"end tell" into tScript
do tScript as AppleScript
put tScript into fld "BigAppleScriptBox" on Card "AlarmStatus"
-------1----------2---------3---------4---------5---------6---------7---------8--------
end myAppleScript
The code below works fine! The delays are important in Applescript, gives the OS/app enough time to open, login, etc. Plus I forgot the 'end tell' would more than likely work without it, by way risk it. - Thanks for pushing me on the white spaces!
NOW WE ARE COOKING!
Again, thanks for the help!
~David
on myAppleScript
put fld "myIMName" on Card "AlarmSettings" into fld "myNewIMName" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMName" on Card "AlarmStatus"
replace cr with "" in fld "myNewIMName" on Card "AlarmStatus"
put fld "myIMBuddy" on Card "AlarmSettings" into fld "myNewIMBuddy" on Card "AlarmStatus"
replace " " with "" in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myNewIMBuddy" on Card "AlarmStatus"
replace cr with empty in fld "myAlarmMessage" on Card "AlarmStatus"
-------------------------------------------------------------------------------
put "tell application" && quote & "iChat" & quote & cr & \
"activate" & cr & \
"delay 3" & cr & \
"log in service" && quote & fld "myNewIMName" on card "AlarmStatus" & quote & cr & \
"delay 4" & cr & \
"set the status message to" && quote & "Status Message" & quote & cr & \
"send " & quote & fld "myTimeField" on card "AlarmMonitor" &" "& fld "myDateField" on Card "AlarmMonitor" & quote & " to buddy "& quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"send " & quote & fld "myAlarmMessage" on Card "AlarmStatus" & quote & " to buddy " & quote & fld "myNewIMBuddy" on Card "AlarmStatus" & quote & cr & \
"end tell" into tScript
do tScript as AppleScript
put tScript into fld "BigAppleScriptBox" on Card "AlarmStatus"
-------1----------2---------3---------4---------5---------6---------7---------8--------
end myAppleScript