Programming Outside The Terminal

Discussion in 'Mac Programming' started by jamesadrian, Sep 24, 2012.

  1. jamesadrian, Sep 24, 2012
    Last edited: Sep 25, 2012

    jamesadrian macrumors member

    Joined:
    Aug 18, 2010
    Location:
    Rochester, NY 14626
    #1
    I have installed Xcode 4.5 and I can compile C source code with gcc to produce an executable program that will run in the OS X terminal window. How can I place this or a similar program on my desktop and have it run from there so that the user need not be familiar with the terminal window? What kind of programming would that take?

    Thank you for your help.

    Jim Adrian
    jim@futurebeacon.com
     
  2. jamesadrian thread starter macrumors member

    Joined:
    Aug 18, 2010
    Location:
    Rochester, NY 14626
    #2
    Programming Outside The Terminal

    This is a programming forum for OS X. Somebody must have some idea about where I should start investigating! I don't have a clue. Please say something.

    I have installed Xcode 4.5 and I can compile C source code with gcc to produce an executable program that will run in the OS X terminal window.

    How can I place a program that performs a similar function on my desktop and have it run from there so that the user need not be familiar with the terminal window? What kind of programming would that take? What key words should I search for?

    Thank you for your help.

    James Adrian
    jim@futurebeacon.com
     
  3. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #3
    We haven't answered because you haven't given us any details about what your program does. There are lots of possibilities. Does the program require user input? Are you looking to make a GUI app?
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    You also haven't told us whether you're a programmer or not. Compiling a C program isn't at all the same as writing one. If you're not a programmer, the options available to you are a lot different than if you are.

    You could start your investigation at Apple's Developer Page, but that's the full range of developer information, not at all specific to getting a Terminal program to have a GUI.
     
  5. jamesadrian thread starter macrumors member

    Joined:
    Aug 18, 2010
    Location:
    Rochester, NY 14626
    #5
    mfram and chown33,

    Thank you for these questions and for allowing me to understand what is needed to start this discussion.

    I have spent most of my career designing and building hardware and programming in the assembly languages of the TMS370156, the 6502, some TMS320 DSP's and that sort of thing. I have only recently begun to learn BASH within the terminal window of OS X and the C programming language.

    The C programs that I have so far and the ones that I am concerned about are each programs that modify files by using the data in two files to arithmetically create a third file. The command line in the terminal requires the name of the program and three file names, the two that are to be operated on and the desired name of the output file.

    The ultimate source of the files is a text editor, like TextEdit. Some of the files created as output in this way contain bytes that are not displayed ASCII bytes, but the final act of each program converts all of the output bytes to displayed ASCII.

    The user needs to be able to select files and the programs that act upon them. The user also needs to select the folder into which the output file is to be placed. I need to place unchanging explanatory comments in the window that offers these choices.

    That is the framework. I will be happy to answer any other questions you may have.

    Where to start is my question. Thank you for helping me get started.

    James Adrian
    jim@futurebeacon.com
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    Thanks for the explanation, it answers a lot of questions.

    Here's a few more:
    1. Who is the audience for the final program? Is it just you? A small group of others like you, who need to easily do whatever it is the program does? The general public?

    2. Do you plan to update the program over time, or is it a single shot? I.e. is there a benefit to learning a large library of tools (Cocoa, Objective-C, Xcode), or is this a case where a quickly-made single-use solution would suffice?

    3. How much time and effort are you willing to put into this? Hours, days, weeks, months?

    4. Is there a deadline for getting this particular program working the way you want?

    5. What range of OS versions does it need to work on?
     
  7. jamesadrian, Sep 25, 2012
    Last edited: Sep 25, 2012

    jamesadrian thread starter macrumors member

    Joined:
    Aug 18, 2010
    Location:
    Rochester, NY 14626
    #7
    Programming Outside The Terminal

    The potential customers are U. S. citizens who speak English; have an interest in history and other academic subjects; and who can operate their email program but may have few other computer skills.


    I would like to evaluate the quicker route first and restart if the inadequacies are unacceptable. Free updates will occur whenever bugs are found and fixed, but otherwise it is a single-shot program.


    Months.


    A year or less if possible.


    Others are independently working on the Linux and Windows versions.


    These are good questions. Thanks.

    I should add that the program need not contain a text editor. Selections can be made with the mouse entirely. I suppose the arrow keys and the enter key could be used as well.

    James Adrian
    jim@futurebeacon.com
     
  8. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #8
    Since you don't have a short deadline, the best thing to do is learn Objective-C and Cocoa, and build the program with Xcode. This is not a quick or trivial undertaking, but it will probably give the best results. It's certainly capable of giving the best results, but a lot depends on how well you use it.

    See the Guides at the top of the Mac Programming Forum.

    Or start at Apple's Developer Home Page with a free registration to get started.


    There are any number of "expedient" approaches, with varying degrees of difficulty and varying possibilities for interaction. Most of them involve learning a scripting language of some kind. Briefly:
    • an Automator workflow with interactive dialogs.
    • an Automator application with drag-and-drop for input.
    • bash script with 'osascript' for presenting dialogs.
    • AppleScript with 'do shell script' for running command-line cmds.
    • Python (several versions possible, including the builtin one)
    • some other scripting language
    I use "expedient" in quotes because it might take more time overall to learn one of those, figure out it won't work well enough, and then end up using Xcode and Cocoa anyway. None of the scripting languages is trivial to learn.

    The Automator workflow or application may severely limit the possibilities for selecting the input and output files.

    Everything has tradeoffs: capabilities, complexity, time, etc.


    You could use Automator.app (in your /Applications folder) to make a Workflow. Drag actions from Library > Files & Folders into a sequence. For example, start with an "Ask for Finder Items" action, check the "Allow Multiple Selection checkbox, and use it to select your two input files.

    Then add an action from Library > Utilities > Run Shell Script, that receives the chosen files and passes them to your command-line tool (the program you have now).

    Finally, figure out how to specify the output file.

    There's plenty of online references and tutorials for Automator.app. Google them.


    You could write a bash script to runs the 'osascript' command to present dialogs that choose the input files. Then you run the command-line tool you have now. The osascript command is a shell-script way to run AppleScript.

    You then wrap the bash script using Platypus, and boom it's double-clickable or even accepts drag-n-drops.


    You could flip that around, and write an AppleScript using AppleScript Editor (in your /Applications/Utilities folder), that runs commands like 'choose file' to select the input files, then runs the 'do shell script' command to run your command-line tool.


    The Python language has extensions that allow simple presentation of dialogs, file-choosers, etc. You can learn Python and use it for the file-picking interaction, and use it to run the command-line tool you have now.

    There are plenty of Python tutorials on the web. Google for them, and be sure to include the keywords mac os x, otherwise you might not learn about the dialog extensions.


    All the above options, and many others I didn't list, will take an investment of time and effort that has nothing at all to do with compiling C or even using the program you have now. You should think of that program as a naked core of functionality that needs to be clothed in an interactive suit of usability. You need to learn how to design and make that suit, and then you can figure out where to put the naked core.
     
  9. jamesadrian thread starter macrumors member

    Joined:
    Aug 18, 2010
    Location:
    Rochester, NY 14626
    #9
    chown33,

    This information is absolutely fabulous!

    I have a lot to look into.

    Thank you enormously for your help.

    James Adrian
    jim@futurebeacon.com
     
  10. theSeb macrumors 604

    theSeb

    Joined:
    Aug 10, 2010
    Location:
    Poole, England
    #10
    Chown has basically covered everything that I was going to post. You basically need to add a GUI using Xcode and Cocoa to wrap the functionality that you've created in your command line C app to make it easier for the user.

    I would recommend going with this approach. You obviously know C so moving to Objective C is not going to be a massive step, if you've worked with C++ or another object orientated language before. Here are two good books to get you going

    http://www.amazon.co.uk/Objective-C...1_fkmr0_2?ie=UTF8&qid=1348737062&sr=8-2-fkmr0

    http://www.amazon.co.uk/Cocoa-Progr...?s=digital-text&ie=UTF8&qid=1348737133&sr=1-1
     

Share This Page