AppleScript Studio Help???...

martinatkinson

Registered
Hello!

I am working on an AppleScript studio application and have a few questions:

1.) I have a file called Strings.strings with the following contents:

help = "Here is a list of available commands and what they do:\n\n1.) ://bugs Opens the bug reporting panel (you may also enter \"://bugs//ACCESSCODE\" to automatically log in).\n2.) ://clear Clears the commander log (not yet enabled).";

I also have the following action in an applescript tied to a button:

set contents of text field "returning" of window "mainWin" to helpstring

My question is this: how would I get "helpstring" to access the "help" string that is in my Strings.strings file?

Thanks!

Albert
 
In my limited knowledge, probably the easiest way would just to have AppleScript do a simple shell script (which is a UNIX command) to call the contents of the string into a variable. That's the way I would do it, anyway -- there's probably a way to have AppleScript itself access the data contents, but since what you're making is going to be MacOS X only anyway, you might as well utilize the command line. :)

Here's how you would do it:

do shell script "cat pathtoStrings.strings"
set somevariablename to result

Now somewariablename is set to the whole contents of that file... then you could use AppleScript or another shell script to parse it (if you know how to do that).

I hope that helps -- I know it's probably not the solution you were looking for, but hopefully it will work in your situation.
 
Hello!

That does not really help in my situation. Thanks for trying though.

BTW: Do you have any idea how to stop AppleScript studio from turning a "\n" into a return in the IDE? I will want it a return in the built application but I would rather just see a "\n" when I am working on the programming.

Thanks for your help!

Albert
 
I just figured out the answer to your second question:

You use the same escape character that UNIX uses: a backslash \. I just realized that a script I saw was using this method.

So to prevent it, just add a backslash before the backslash of \n. You can also do this if you want to add quotes in a dialog as in:

display dialog "\"Hello!\""

Isn't that cool? :)
 
Hello!

Ok, thanks, that works!

Another question. I am using a text field as sort of a log, so when I complete an action it adds text to the end of the text field. In REALbasic I used:

textField.text=textField.text+" Some more text"

So if the textField controls contents were "This is the contents" and the above action was added to a button it would now read "This is the contents Some more text"

Do you know how I would do this in AppleScript or Cocoa?

Thanks!

Albert
 
It's pretty similar in AppleScript:

set variablename to (variablename & " whatever else you want here") as string

If variablename is already a string before you issue this command, you won't need the "as string" or the parentheses.
 
Hello!

Thanks, I will see if this works. One question. Is there any way to declare all your variables in one AppleScript file and then in the top of another use the include "variables.applescript" or something?

Thanks!

Albert
 
Back
Top