Couple of Xcode questions

Discussion in 'Apple' started by JF Mezei, Apr 22, 2014.

  1. JF Mezei

    JF Mezei Guest

    So, I am wasting much time trying to get a simple AppleScriptObjC to
    run. :-(

    Question: Is there a magic incantation to change the font of the
    displayed code ?

    Edit -> Format -> Font -> Show fonts lets you choose fonts, but no
    change to code.

    Similarly, Edit -> Format -> Font -> Bigger has no effect,

    When it gets late, one has to get bigger font (especially since turning
    off text colouring has no effect, Xcode continues to insist to colour it).

    Secondly, when compiling the Appescipt, is it normal that the only
    details of a compilation error would be hidden into a pane you have to
    click on and reveal:

    slideprintAppDelegate.applescript:30: error: Expected “,” or “)” but
    found identifier. (-2741)
    Command /usr/bin/osacompile failed with exit code 1

    I would have thought a modern IDE would have had some flashing arrow
    pointing to the error in the source code. Yet, I find no indication of
    where in the applescript an error was found.

    Or did Apple disable the goodies between 3.1 and 3.2 to force people to
    bguy Xcode 4 and beyond ?

    Also, while I am at it, since there appears to be no debgger support for
    Applescript, I am resorting to "display dialog". However, is there a
    trick to display a numeric value ?

    for instance:

    set x to 24
    display dialog x

    (I tried many incantations, but lack of proper compiler errors means I
    operate in the dark).
    JF Mezei, Apr 22, 2014
    1. Advertisements

  2. JF Mezei

    JF Mezei Guest

    I hate these newfangled languages with insufficient documentation.

    Seems that contrary to what they say, "set myvar to 1" is not sufficient
    to declare a variable.

    In an AppleScriptObjC environment, it appears no code executes by
    default. And it *appears* that the "on <event> <code> end" blocks are
    treatead as subroutines, so if you want variables to be accessible
    accross those blocks, they have to be declared as "global" at the top of

    (The doc and examples all said that a "set myvar to 1" at the top was
    enough to declare the variable).

    Also, it appears that the automatic coversion from number to string as
    some of the documentation alludes is not so automatic.

    my display dialog of a number was failing because the variable had not
    been initialised and not availble to that block :)

    display dialog myvariable as string

    does the trick.

    Hours wasted because of that newfangled documentation. Long live the VMS
    wall where you got the whole story on how stuff worked.

    And now, I will have fun trying to integrate the serial port support. It
    is likely 32 bits, and if I can't recompile it to 64 bits will have to
    create my small simple app as 32 bits.

    BTWm the "number formatter" in interface builder is really really basic.
    It lets you enter anything of any length and only validates once you try
    to leave the field. 1980s character cell tech did this live as you typed
    and wouldn't let you enter a letter in a numeric field.
    JF Mezei, Apr 22, 2014
    1. Advertisements

  3. JF Mezei

    JF Mezei Guest

    Ok, so this serial interface to appelscript provides and ".OSAX" file
    put into scripting additions.

    How does one add this to an xcode project ? (apparently it has a
    dictionary with the valid statements etc, which would be visible in the
    applescript editor, but not sure how this works in Xcode)
    JF Mezei, Apr 22, 2014
  4. JF Mezei

    Lewis Guest

    In what editor?
    Um, that's not how script editor behaves for me, but you didn't say what
    you were using.
    osacompile? Are you writing in Xcode? Don't do that. Script Editor works
    very well for almost all AppleScript work. You only want to resort to
    XCode if you are building something complicated with lots of files. A
    UI. Stuff like that.
    You are using XCODE 3?!? The current version is 5.1.1

    And yes, I'm sure Apple is very interested in the income derived from
    forcing people to buy $0 upgrades to XCode.
    To the best of my recollection:

    display dialog (x as text) giving up after 5 seconds
    Lewis, Apr 22, 2014
  5. JF Mezei

    Don Bruder Guest

    Nope, they're more interested in the income from forcing people to buy
    the $whatever-the-price-is-today machine that *CAN* run the newest
    Don Bruder, Apr 22, 2014
  6. JF Mezei

    Guest Guest

    Nope, they're more interested in the income from forcing people to buy
    the $whatever-the-price-is-today machine that *CAN* run the newest

    xcode runs just fine on 5 year old macs, which means your statement is
    complete bullshit.
    Guest, Apr 22, 2014
  7. JF Mezei

    JF Mezei Guest

    I was under the impression that the last "free" version of xcode was 3.2
    and that starting with 4, once needed a paid subscription to apple
    developper to get the free xcode.

    Is that still the case, or is xcode now freely downloadable again ?

    would xcode 5 work on Snow Leopard ?

    The normal Applescript Editor does not provide access to the Interface
    Builder. It is means to script existing applications instead of building
    a standalone one.

    The use of Xcode is required when you want to attach a GUI (interface
    buioder) to an applescript application.
    JF Mezei, Apr 22, 2014
  8. JF Mezei

    Guest Guest

    you remember wrong. xcode is free with any level developer account,
    including free) and also available for free on the app store.
    mountain lion required.
    Guest, Apr 22, 2014
  9. JF Mezei

    JF Mezei Guest

    OK, I need to add parity to my memory :-(

    I was pretty sure at one point Apple started to require paid developper
    subscriptions for Xcode upgrades (hence why I stopped bothering after
    Xcode 3.2)
    JF Mezei, Apr 22, 2014
  10. JF Mezei

    Guest Guest

    they didn't.

    however, they did briefly charge for xcode on the app store, but all
    you had to do was register as a free developer and get it for free that
    Guest, Apr 22, 2014
  11. JF Mezei

    Lewis Guest

    Lewis, Apr 23, 2014
  12. JF Mezei

    Alan Baker Guest

    Why not just do it in AppleScript?
    Alan Baker, Apr 23, 2014
  13. JF Mezei

    Alan Baker Guest

    Hey...'s a CRAZY thought.

    Why don't you actually check some of these things out...

    ....for yourself?
    Alan Baker, Apr 23, 2014
  14. JF Mezei

    JF Mezei Guest

    not easy because most of Google stuff on Applescript/Xcode interface
    predates the change from Applescript Studio to ApplescriptOBJC.

    And I had to do my own testing to find out that for Applescript Editor,
    scripting additions placed in the Library/Scripting Additions are
    automatically available to the Applescript app. Now, I must do the same
    to see if they are also available to the AppleScriptObjC in Xcode.

    I was hoping someone had gone through this before and could give some
    hints that would have saved me archeological digs that have taken hours
    so far to learn a tech that was meant to allow me to do this simple task
    in a couple of minutes.
    JF Mezei, Apr 23, 2014
  15. JF Mezei

    JF Mezei Guest

    AppleScript Editor has a "open dictionary" function. Xcode doesn't.
    AppleScript Editor automatically finds files in Scripting Additions.
    There is no documentation on whether Xcode does that or not.

    There is documentation on how to produce a scripting addition in Xcode,
    but not how to use one.
    JF Mezei, Apr 24, 2014
  16. JF Mezei

    Alan Baker Guest

    So use AppleScript Editor.

    I've written most of the script while you've been making excuses.
    So use AppleScript Editor.

    I've written most of the script while you've been making excuses.
    Alan Baker, Apr 24, 2014
  17. JF Mezei

    JF Mezei Guest

    Repeating for the Xth time: AppleScript Editor does not allow building
    against interface builder. You need Xcode for that.

    You need Xcode to link the properties defined in Applescript to the
    fields in interface builder, and the buttons in interface builder to the
    "on" code blocks in AppleScript.

    Unless of fcourse I read wrong and that capability also exists in
    AppleScript Editor along with all the AppleScriptObjC extensions needed
    to work with interface builder's Cocia interface.

    BTW, Xcode does seem to find the osax in /Library/ScriptAdditions
    without having to add it to the project. Not very obvious in a IDE where
    you are expected to explicitely specify all the libraries a project uses.

    Will now have to try to run this on the server where there are real
    serial ports.

    But now, I have to figure out a way to bind the "return" key to a
    button. IT seems to want it binded to a text field.
    JF Mezei, Apr 24, 2014
  18. JF Mezei

    JF Mezei Guest

    I've had some success.

    It is interesting that running the script on a machine without the
    serial port entension does not generate any errors, except that the log
    does have complaint about missing variable (which has been defined).

    Also, when there is such an error in the

    on applicationShouldTerminate_(sender)
    if theport > 0 then serialport close theport
    return current application's NSTerminateNow
    end applicationShouldTerminate_

    Then you must "force quit" the application, because of the error in the
    "quit" code (complains about undeclared theport, but really about
    missing definition of "serialport".

    Once I got all setup on the server, the app was able to send data to the
    serial port. Hurray !. But it does log this message to the console:

    14-04-24 03:32:14 slideprint[13337] Performance: Please update this
    scripting addition to supply a value for ThreadSafe for each event
    handler: "/Library/ScriptingAdditions/SerialPort X.osax"

    The source to that serial port osax is not provided. Is there a way to
    fix it ? I can live with this as this app should not be used that many
    JF Mezei, Apr 24, 2014
  19. JF Mezei

    Paul Sture Guest

    I missed this thread when it was current, and would have suggested Python
    instead. The advantages with Python are that there are tons of libraries
    available AND lots of questions and answers on the likes of Stack Overflow.
    Paul Sture, May 10, 2014
  20. So Python is the next new shiny thing(tm). I've been using perl for at
    least at decade, mostly because it's so extensible, has a huge number of
    modules for everything under the sun, and it's been around for so long.
    I mentioned perl to a Objective C/java developer and he made a face
    (varkripta punim actually).

    Not to start a language flamewar, but why Python over something else?
    Usually, I say "write it in the language you know best".

    Just curious.
    Michael Vilain, May 10, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.