||<< Index >>||
|Appendix J - Command Line Tools||appendix|
_buildAsCommandLineTool= _true // _true or _false
A command-line tool always has at least one argument: the path to the command. More arguments may follow if the tool was run via a terminal or pipe.
$ ./test.command 123 nine "a quoted string"
Number of arguments = 4
a quoted string
The command line tool can read any named environment variable from the host environment list as illustrated below:
Standard input and output
In a tool, the
input statement reads from stdin and the
Note that only the first 255 characters will be read, or up to the newline character, whichever comes first.
A tool can perform any file-system operation except display a navigation dialog. Several functions in Util_FileDirectory.incl allow access to files in predictable locations. FD_PathGetFSRef() and FD_PathCreateCFURL() can be used to convert a path, passed as a tool argument, to a FSRef or CFURLRef.
Command line tools (but not console apps) can be compiled in 64-bit mode. This is done by putting "-m64" into FBtoC's 'More compiler options'. That setting tells the compiler to produce a 64-bit executable instead of the older 32-bit kind.
How to make an Xcode project from a FutureBasic command-line tool
 Put an Info.plist file in the same folder as the FutureBasic source. The xml content can be vacuous.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 Set Optimization to None in build settings.
 Build and Run the FutureBasic source. You can either leave toolname.command running in Terminal.app or kill it.
 Choose Command > Make Xcode Project.
 In Xcode, Build and Run the translated C source. To see the output, ensure that Xcode's Debugger Console is shown, perhaps by choosing the command Run > Console.
 By appropriate manipulations in the Finder you can drag the executable from "build_temp/XcodeProject/build/Debug/toolname.app/Contents/MacOS/toolname" to a more sensible location.
 A later release of FutureBasic (version 5 onwards) may provide a special Xcode project template to make step #1 unnecessary and step #6 simpler.