reverse reader

Here is the problem. I wrote a small but efficient script - though I am still quite a newbie - and saved as a run-only app. The script does exactly what I need it to do. But I cannot remember what I wrote so I can replicate and modify it for other similar uses. I forgot to save a text version of the file so I would have something to go back to.

Is there any application that will allow me to go back and view my original script from the finished product? I have tried countless variations upon what I thought I had done the first time and none of them work. I need to find out what I did right that first time [or more accurately, 15th or 16th time].

By the way, the whole script is very simple. I have a calendar program called “Expresso” that will make the background of my screen a calendar when I quit it. All I wanted my script to do was sit in my Startup Items and started up my calendar program so it would update each day when I start my computer. I know it is something like the following, but I also know that for some reason this script doesn’t work.

tell app "Finder"
 activate "Macintosh HD:Applications (Mac OS 9):Expresso:Expresso"
 quit
end tell

I don’t know why it won’t work or what I did differently in the one that does. Any help to get me back into my original program - or fix this script - appreciated.

Thanks
jmax

: Here is the problem. I wrote a small but efficient script - though I am still
: quite a newbie - and saved as a run-only app. The script does exactly what
: I need it to do. But I cannot remember what I wrote so I can replicate and
: modify it for other similar uses. I forgot to save a text version of the
: file so I would have something to go back to.

: Is there any application that will allow me to go back and view my original
: script from the finished product? I have tried countless variations upon
: what I thought I had done the first time and none of them work. I need to
: find out what I did right that first time [or more accurately, 15th or
: 16th time].

: By the way, the whole script is very simple. I have a calendar program called
: “Expresso” that will make the background of my screen a calendar
: when I quit it. All I wanted my script to do was sit in my Startup Items
: and started up my calendar program so it would update each day when I
: start my computer. I know it is something like the following, but I also
: know that for some reason this script doesn’t work.

: tell app “Finder” activate “Macintosh HD:Applications (Mac OS
: 9):Expresso:Expresso” quit end tell

: I don’t know why it won’t work or what I did differently in the one that
: does. Any help to get me back into my original program - or fix this
: script - appreciated.

There’s no way to recover the code for a script saved as read-only. You should only save things that way if you have code in a script that you don’t want other people to be able to read. For your script try:

tell application "Macintosh HD:Applications (Mac OS 9):Expresso:Expresso"
    activate
    quit
end tell

Marc K. Myers
Marc@AppleScriptsToGo.com
AppleScriptsToGo
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[3/14/02 10:49:37 AM]

Marc is absolutely right - that’s the whole idea of ‘run-only’. There is, though, one (pretty hopeless) thing you can try. In ResEdit if you open the ‘scpt’ resource “using Hex Editor” you may just be able to decipher enough of the visible aevt’s and text to get a clue to what you are looking for. Don’t hold your breath - the chances of success are very slim!

Andreas

Hi Marc and Andreas,
I am sorry that you didn’t seem to really read the remark I made, I effectively suggested it was in there; I am also sorry that you are not open minded enough to try something before you blow your mouth off with a lack of knowledge. I have done this, I didn’t say it always worked, but it has for me and that was what I was suggesting to the poster of the piece. I maynot be a great scriptor, but I have had more than a passing bit of experience with Macs’ (over 15 years of resource editing, coding and learning about it).
Also, I was not at my Mac when I wrote my first post so did not have the chance to get the exact resource id needed. Both of you need to open your eyes and see that maybe there are ways of finding this by looking around what’s available.
Cheers,
BlackMac

: Hi Marc and Andreas,
: I am sorry that you didn’t seem to really read the remark I made, I
: effectively suggested it was in there; I am also sorry that you are not
: open minded enough to try something before you blow your mouth off with a
: lack of knowledge. I have done this, I didn’t say it always worked, but it
: has for me and that was what I was suggesting to the poster of the piece.
: I maynot be a great scriptor, but I have had more than a passing bit of
: experience with Macs’ (over 15 years of resource editing, coding and
: learning about it).
: Also, I was not at my Mac when I wrote my first post so did not have the
: chance to get the exact resource id needed. Both of you need to open your
: eyes and see that maybe there are ways of finding this by looking around
: what’s available.
Also, if I am wrong, than I am wrong.
: Cheers,
: BlackMac

Because you sound so positive (bombastic? defensive?) I just created a small run-only app and checked it in ResEdit. I stand by what I wrote, and I agree totally with what Marc wrote.

If you are right why not offer reason rather than rudeness? You are not under attack. If you can teach us something then please do - but preferably in terms a bit less vague than so far.

Better still may I suggest that you obtain jmax’s app and return it to him in editable form. Jmax will be delighted and I assure you that I will then be very impressed.

Andreas

Andreas and Marc,
I must apologize, I was simply offering a line that the poser of this thread might want to try; if I offended you, sorry. I though standby what was suggested (and that is all I did) that sometimes it is possible with a little massaging of the file to get much of what is sought. I am sorry that either of you took my suggestion as anything more than that. I never professed to being a guru.
That said, I did post a question of my own regarding OS X and Applescript, and as you are better at this than I, would you mind helping out this poor misled soul. My topic as Folder moving with OS X.
Cheers.

No, Sir, you were certainly not simply offering. You were extraordinarily rude. Marc Myers, in particular, is one of the most respected contributors to this site. Your audacity to refer to him in such a vulgar way beggars belief.

I hope that your realization of a need to apologize for both your insolence and the nonsense you wrote will serve to make you more cautious should you ever again have anything to say.

A

Hi,
There is a way to read the script code you wrote for the applet; it involves opening up the applet in ResEdit, and looking for a resource “scpt” (I believe) or something like that; therein should be resource Ids and one of those should have the entire (though saved as text) script code you created). If it’s not there, it may be in the “text” resource. It doesn’t always work, but often does.

: Hi,

: There is a way to read the script code you wrote for the applet; it involves
: opening up the applet in ResEdit, and looking for a resource
: “scpt” (I believe) or something like that; therein should be
: resource Ids and one of those should have the entire (though saved as
: text) script code you created). If it’s not there, it may be in the
: “text” resource. It doesn’t always work, but often does.

The “scpt” resource contains binary code. The “TEXT” resource contains an explanation of what an applet is. I don’t know how you’d ever reconstruct the code for a script from that.

The reason that there is a capability for saving scripts as read-only is to keep people from being able to read your code. Apple’s not so stupid as to blow that by putting the code in a resource. There has never been a way to read the code of a read-only script.

Marc K. Myers
Marc@AppleScriptsToGo.com
AppleScriptsToGo
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[3/20/02 1:08:05 PM]

: Marc is absolutely right - that’s the whole idea of ‘run-only’. There is,
: though, one (pretty hopeless) thing you can try. In ResEdit if you open
: the ‘scpt’ resource “using Hex Editor” you may just be able to
: decipher enough of the visible aevt’s and text to get a clue to what you
: are looking for. Don’t hold your breath - the chances of success are very
: slim !
: Andreas

Using an HexEditor won’t tell you more than resedit for the simple reson that Resedit has an HexEditor. However, I’m starting from the point that if the computer is understanding the script, we should be able to do so.

Take for example Script Spy v1.0.9 made by Rob Jorgensen, it searches in script if they are harmful events even if it is a run-only script.

Does anyone know if they is any documentation by apple or someone else on such subject?

Jean-Baptiste LE STANG

Andreas and Marc,
Apparently this is going to turn into character assassination and therefore I will do the following:
I apologize for my rudeness and apparent insolence towards either and both of you.
BlackMac

Jean-Baptiste, if you read more carefully you will see that I wrote:

In ResEdit if you open the ‘scpt’ resource “using Hex Editor” I tend to assume that those using ResEdit have at least a knowledge of what is available in its menus.

This thread appears to have become a stage for those wishing to strut by scoring points over others. Please continue, but without

Andreas

I’m sorry for such a trouble. I misunderstood your answer because I read it to quickly, but I’m offended by what you’re insinuating about me in your answer.

1 - I’m respecting the work of every one on this BBS because what everybody is doing is important. I appreciate more particulary the work made by you an Mark because most of the time you are giving proper answers to our problems.

2 - I’m here to learn from my mistakes, and I don’t think that I’ve your knowledge on Applescript, far for from me the idea of giving you a lesson or whatever. I don’t think that I ever was impolite with you? Did I offend you once?

3 - I’d like to add that English/American is not my mother tongue as you must have already noticed which can explain why sometimes I miss the meaning of a message, or make so much horrible mistakes in my answers, so be indulgent with me

Sincerly
Jean-Baptiste LE STANG

Jean-Baptiste - You are making me break my promise to myself to say no more in this thread. I was not so much annoyed with you as with the whole flavour that had emerged, and that I wanted to get away from. You have always been - and still are - extremely courteous.

Et ta Anglais est mille fois meilleur que ma Francais execrable!

Rob Jorgensen says in different words what I said earlier

with the difference that Rob has done a lot of serious work on this where I am just the amateur peering in. The point I was making is that a third party looking at the 'aevt’s (and the snippets of ‘text’ that remain) is virtually certain to learn nothing of value but the author of the app might just - if he is incredibly lucky - be reminded of something he wrote.

And the moral of the story is No, Jmax, I won’t rub it in!

Andreas

: Using an HexEditor won’t tell you more than resedit for the simple reson that
: Resedit has an HexEditor. However, I’m starting from the point that if the
: computer is understanding the script, we should be able to do so.
: Take for example Script Spy v1.0.9 made by Rob Jorgensen, it searches in
: script if they are harmful events even if it is a run-only script.
: Does anyone know if they is any documentation by apple or someone else on
: such subject?

When I was writing Script Spy, I asked about run-only scripts on one of the AppleScript lists. Chris Nebel, of the AppleScript Engineering team, replied with this:

“AppleScript never stores the source text in a saved script, it just saves enough information to let it reconstruct the source, assuming all the terminology is still available. (This is why scripts turn into raw event codes if an application goes missing.) A run-only script strips out most of that information, leaving only enough to execute the script. This happens to include the event codes.”

Pretty simple, eh? :wink:

Script Spy just peeks at the events stored in a run-only script and compares them to a pre-defined list (which everyone should modify to suit their own environment and comfort level).

Later,
Rob J