home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ob140os2.zip / OMNIBASI.FAQ < prev    next >
Text File  |  1996-07-14  |  10KB  |  170 lines

  1.  
  2. Q: What is the history of OmniBasic?
  3. A: OmniBasic is the C output version of CDL Basic which was a native code
  4.    compiler for the OS9/68000 operating system. Since OmniBasic now
  5.    produces C code, it is now quite portable to most any platform.
  6.  
  7. Q: What language was OmniBasic written in?
  8. A: OmniBasic was written in OmniBasic. The early version was written in
  9.    its predecessor CDL Basic. This is not unusual in itself in that most
  10.    C compilers were written in C. What is unique is having a Basic that
  11.    is powerful enough to be used to compile itself.
  12.  
  13. Q: What can OmniBasic do that other Basics cannot do?
  14. A: In general, the answer is produce systems programs. Attempting to
  15.    write systems code in most Basics usually results in the use of
  16.    PEEKing and POKEing and other "tricks". OmniBasic has all the power
  17.    and utility of C but without the cryptic and often terse syntax of C.
  18.    These include pointer variables, dynmamic buffer allocation, internal
  19.    and external functions, function pointers, conditional compilation,
  20.    include files, macros, structures, compiler variables (manifest
  21.    constants), command line arguments, and others.
  22.  
  23. A: What does OmniBasic have that C does not have?
  24. Q: The first thing is that OmniBasic is easier to learn and use than C. The
  25.    second is that OmniBasic provides more meaningful (and accurate) reporting
  26.    of compile time errors than most C compilers. The third is full STRING
  27.    capability (in OmniBasic, STRING is a bonafide data type not an external
  28.    afterthought). The fourth is VECTOR (based) variables. These are similar
  29.    in concept to pointers, but as easy to use as ordinary variables. The
  30.    fifth is portability. While C made portability famous, data structures
  31.    in one C and another (even on the same computer) are often "padded"
  32.    differently (just do a sizeof and see for yourself). In OmniBasic, all
  33.    data structures are declared as a char array with ALL internal management
  34.    and referencing handled by OmniBasic. The sixth is the ability
  35.    to exchange and transfer all data types (including arrays) in a single
  36.    statement. Exchanges are especially useful for sorting data.
  37.    OmniBasic has all the features of Basic which means it is a higher level
  38.    language than C. (C is variously referred to a a mid-level langauge or
  39.    universal assembler). This unique set of features makes OmniBasic
  40.    equally at home at systems as well as applications programming.
  41.  
  42. Q: Since OmniBasic produces C code, do I need a C compiler also.
  43. A: Yes. The type of C compiler required depends on the system being used.
  44.    In most cases there is a GCC compiler available from the Free Software
  45.    Foundation which is an fine compiler. OmniBasic automatically invokes
  46.    the C compiler if you have the standard one for that system. If not,
  47.    the Basic program may be invoked with the -c option which causes the
  48.    compile process to stop with the generation of the .c file. This .c
  49.    file may then be used as input to your C compiler.
  50.  
  51. Q: Is there any runtime package required?
  52. A: No. Unlike interpreters and I-Code compilers, the output of OmniBasic
  53.    is compiled by your C compiler to pure machine code which is not only
  54.    fast and efficient but requires no runtime package.
  55.  
  56. Q: Since OmniBasic produces C code, do I need to know anything about C?
  57. A: No. In fact, unless you invoke the -v (verbose) option, you will not
  58.    even see the C compiler being called.
  59.  
  60. Q: How does OmniBasic implement Basic subroutines?
  61. A: Subroutines are implemented as void functions.
  62.  
  63. Q: Does OmniBasic support structured programming techniques?
  64. A: Yes. Various control structures are available including FOR/NEXT,
  65.    WHILE DO/ENDWHILE, REPEAT/UNTIL, IF/ELSE/ENDIF, LOOP/EXITIF/ENDEXIT/
  66.    ENDLOOP.
  67.  
  68. Q: Do I have to use structured programming techniques?
  69. A: No. You can make your program as structured or unstructured as you
  70.    wish (or anywhere in between).
  71.  
  72. Q: Will programs I write in OmniBasic on Linux run on MSDOS?
  73. A: Yes, if you recompile the program on the MSDOS system.
  74.  
  75. Q: Is the C code produced ANSI compatible or K&R compatible?
  76. A: Both. The K&R must have the "void" extensions (which most do). The
  77.    input/output operations make use of the unbuffered calls such as
  78.    read(), write(), etc. (as opposed to fread() and fwrite() etc.) which
  79.    means that your C compiler must have the System V (or Posix) extensions
  80.    (most all do).
  81.  
  82. Q: IF OmniBasic is as powerful as C, then how is it easer to learn and use?
  83. A: First, as a beginner on OmniBasic, you can use the more traditional
  84.    Basic features and work your way into the more advance features as you
  85.    progress. Second, the advanced features are easier to learn and use than
  86.    those in C and the syntax is more English-like than C. Also, while
  87.    OmniBasic does have pointers like C, the Vector (based) variable allows
  88.    the same power as the pointer without any pointer syntax at all.
  89.  
  90. Q: Is OmniBasic able to use the vast array of C functions and libraries on
  91.    the market and in the public domain?
  92. A: Yes. Some of the C "string" functions may require careful consideration
  93.    but there is already a full array of STRING functions included with
  94.    OmniBasic as an integral part of the language.
  95.  
  96. Q: I notice there are is no graphic capability built into OmniBasic. How
  97.    do I do graphics.
  98. A: Since OmniBasic can call C funtions equally as well as C can, you have
  99.    full access to the C graphic libraries for your system.
  100.  
  101. Q: Of what practical use is the conditional compilation capability?
  102. A: One example of this is the OmniBasic compiler itself. While there are
  103.    a variety of versions available (regular and demo) (Linux and MSDOS) etc.,
  104.    there is only one master source file in which any differences in the
  105.    various versions are enclosed in conditional code blocks. When a version
  106.    is compiled, the command line specifies (by setting a compiler variable)
  107.    which version will be compiled. You might want to use this concept to
  108.    produce different versions of your own program. Different versions might
  109.    include special features or different language prompts etc.
  110.  
  111. Q: What is the advantage of named labels over line numbers?
  112. A: Line numbers convey no intrinsic meaning while named labels can be
  113.    quite desciptive, thus enhancing readability. For example, GOSUB 1435
  114.    gives no clue, while GOSUB PrintChecks is quite clear.
  115.  
  116. Q: What are compiler variables?
  117. A: Compiler variables are named constants (referred to also as manifest
  118.    constants). Like named labels, these increase a program's readability.
  119.    These are not to be confused with program variables but are, in fact,
  120.    named literal values. They are especially useful for naming flags and
  121.    indicators. For example, after setting a named constant (#SET Red=22),
  122.    it has a clearer meaning to write Color=Red than to say Color=22.
  123.  
  124. Q: How do I look at the C code that OmniBasic generates?
  125. A: Just compile your program with the -c command line option. Then list out
  126.    the resultant .c file. Each OmniBasic statement will appear as a C
  127.    comment followed by the resultant C code. If you wish, these comments may
  128.    be omitted by using the -r option with the -c option (-cr).
  129.  
  130. Q: What is dynamic buffer allocation used for?
  131. A: Sometimes when you are writing a program, you have no way of knowing
  132.    how large to diminsion an array. You won't know this until the program
  133.    is run and you can (for example) check the size of an input file. In
  134.    this case, you can check the size of the file (using the FILSIZ()
  135.    function), request the required amount of memory, and set a vector (based)
  136.    variable to the memory buffer address. You can then operate on the array
  137.    just as if it were diminsioned the standard way. In standard Basics this
  138.    problem is solved by diminsioning an arbitrary array size, and then if the
  139.    arbitrary size is too large, you waste memory space, and if it is too
  140.    small, the data must be operated on a little at a time.
  141.  
  142. Q: Do I have to worry about the fact that in C, arrays start with 0?
  143. A: No. OmniBasic automatically compensates for this so that your arrays can
  144.    start with 1. There is a BASE statement in which you can select either
  145.    0 or 1 as the base fore arrays. The default is 1.
  146.  
  147. Q: Is there bounds checking on arrays?
  148. A: No. This speeds up execution speed but does require some caution on the
  149.    part of the programmer. Strings are bounds tested so that if you input
  150.    22 characters into a 20 character string, the worst that happens is the
  151.    string is truncated. The next variable in memory is NOT clobbered as in
  152.    some cases with C.
  153.  
  154. Q: Can OmniBasic be used to write system utilities?
  155. A: Absolutely! Since OmniBasic progams end up as pure machine language
  156.    programs you can write your own system utilities and use them just
  157.    like the ones that came with your system. You can even "read" options
  158.    from the command line and use these options to control the flow of
  159.    your program.
  160.  
  161. Q: How can I treat the same variable as more than one type?
  162. A: You can diminsion vectors or pointers of various data types and then
  163.    set them to the same address. For example it is possible to diminsion
  164.    x as a long (32 bit integer), y as a 4 byte array vector, set y to the
  165.    address of x and then operate on the same data as either type.
  166.  
  167. Q: What is the distinction between "program" and "function" in OmniBasic?
  168. A: Program refers to the main body of code which in C is the main() function.
  169.    while function refers to any non-main function in C.
  170.