home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / basic / lb09c.zip / DIFFRNCS.TXT < prev    next >
Text File  |  1993-02-22  |  8KB  |  277 lines

  1. The GWBASIC to Liberty BASIC Survival Guide
  2. -----------------------------------------------
  3.  
  4. Liberty BASIC is designed to be a lot like GWBASIC, but there are
  5. differences.  Some of these differences are incompatibilities, and
  6. some are enhancements.  Some things that are missing from this
  7. evaluation copy of Liberty BASIC 0.9c are included in the
  8. registered version.
  9.  
  10. Here you will find information about:
  11.  
  12.   PRINT                 File Handles
  13.   INPUT                 INPUT$()
  14.   Variable Names        Boolean Operators
  15.   Variable Types        TIME$(), DATE$()
  16.   Line Numbers          Random Numbers
  17.   DIM
  18.   ELSEIF...ENDIF
  19.  
  20.  
  21. PRINT
  22. ---------------------------------------------------------------------
  23.  
  24. PRINT is -almost- the same.  The comma cannot be used as a formatter.
  25. For example:
  26.  
  27.     print a, b, c
  28.  
  29.   is valid in GWBASIC, but not in Liberty BASIC
  30.  
  31. Also, PRINT USING isn't supported, but there is a using( function
  32. instead.
  33.  
  34.   GWBASIC:        print using "The total is #####.##", ttl
  35.   Liberty BASIC:  print "The total is "; using("####.##", ttl)
  36.  
  37. GWBASIC inserts spaces before and after numbers (called padding) when 
  38. it prints them.  Liberty BASIC also does this, but this feature can 
  39. be turned off if you prefer to do custom output formatting.  To turn 
  40. it off, Pull down the Setup menu, and select Compatibility.  Then 
  41. select the PRINT line to turn off BASIC's padding feature.  This will
  42. remain in effect until you decide to change it.
  43.  
  44.  
  45. INPUT
  46. ---------------------------------------------------------------------
  47.  
  48. GWBASIC permits this:
  49.  
  50.     input "Give me the next number"; n(x)
  51.  
  52. In Liberty BASIC, you must do this:
  53.  
  54.     input "Give me the next number"; n
  55.     n(x) = n
  56.  
  57. GWBASIC automatically adds a question mark and an extra space onto the
  58. end of the prompt (using above as example: Give me the next number? _).
  59. Liberty BASIC lets you disable this if you prefer so you can do it your
  60. own way.  For example:
  61.  
  62.     input "Give me the next number >"; n
  63.  
  64.   appears as:
  65.  
  66.     Give me the next number >_
  67.  
  68. To disable BASIC's automatic adding of the question mark, pull down
  69. the Setup menu and select Compatibility.  Then select the INPUT line
  70. to disable it.  This will remain in effect until you decide to change
  71. it.
  72.  
  73.  
  74.  
  75.  
  76.  
  77. Variable Names
  78. ---------------------------------------------------------------------
  79.  
  80. Liberty BASIC accepts GWBASIC variable names.  But it also lets you
  81. use upper and lower case letters.
  82.  
  83.   someTime   and   sometime 
  84.   
  85.   are considered different variables in Liberty BASIC.
  86.  
  87.  
  88.  
  89. Variable Types
  90. ---------------------------------------------------------------------
  91.  
  92. Liberty BASIC only supports two variable types, numeric and string.
  93.  
  94. The numeric variable holds either an integer or real value, and in
  95. this case Liberty BASIC optimizes automatically.  If a real loses
  96. its non-integer part through some calculation, then Liberty BASIC
  97. converts it into an integer to speed up operations.  Integers can be
  98. enormously large (see factorial.bas).  Reals are single precision.
  99.  
  100. The string variable holds a character string that can be as large as
  101. available memory.
  102.  
  103.  
  104.  
  105. Line Numbers
  106. ---------------------------------------------------------------------
  107.  
  108. Liberty BASIC lets you use the conventional line numbers if you like.
  109. You can also choose not to use them, and use descriptive branch labels
  110. instead.  For example:
  111.  
  112. In GWBASIC:
  113.  
  114.   10 print "Let's loop!"
  115.   20 x = x + 1
  116.   30 print x
  117.   40 if x < 10 then 20
  118.   50 print "Done."
  119.   60 end
  120.  
  121. In Liberty BASIC:
  122.  
  123.      print "Let's loop!"
  124.   [mainLoop]
  125.      x = x + 1
  126.      print x
  127.      if x < 10 then [mainLoop]
  128.      print "Done."
  129.      end
  130.  
  131.   You can see here that instead of jumping to line 20, as in the first
  132.   example, we can instead jump to [mainLoop].  You can name your
  133.   branch points and subroutines whatever you like.  They need to start
  134.   and end with [ and ], respectively, and they can't have any spaces.
  135.  
  136.   Legal branch labels:
  137.  
  138.     [mainLoop]
  139.     [loop1]
  140.     [exceptionHandler]
  141.  
  142.   Illegal branch labels:
  143.  
  144.     [main loop]
  145.     mainLoop
  146.  
  147.  
  148.  
  149. DIM
  150. ---------------------------------------------------------------------
  151.  
  152. The DIM statement can only dimension ONE array per statement, so 
  153. instead of:
  154.  
  155.     dim a(20), b(20), c(20)
  156.  
  157.   do this:
  158.  
  159.     dim a(20) : dim b(20) : dim c(20)
  160.  
  161.  
  162.  
  163. ELSEIF...ENDIF
  164. ---------------------------------------------------------------------
  165.  
  166. Liberty BASIC supports IF...THEN...ELSE, but not the ELSEIF...ENDIF
  167. combinations.
  168.  
  169.  
  170.  
  171. File Handles
  172. ---------------------------------------------------------------------
  173.  
  174. GWBASIC lets you use only numbers as file handles.  Liberty BASIC lets
  175. you use numbers, and it lets you use letters also.
  176.  
  177.   open "autoexec.bat" for input as #1 ' GWBASIC
  178.  
  179.   open "autoexec.bat" for input as #autoexec  ' Liberty BASIC
  180.  
  181. Now here's the catch.  Whenever you reference the file handle, you
  182. MUST use have a # in front of it.
  183.  
  184.   if eof(1) > 0 then 10020 ' GWBASIC
  185.  
  186.   if eof(#autoexec) > 0 then [reachedEnd]  ' Liberty BASIC
  187.  
  188. Additionally:
  189.  
  190.   print # 1, "buffers = 30"  ' this works fine in GWBASIC
  191.          ^--------this extra space not allowed in Liberty BASIC
  192.  
  193.  
  194.  
  195. INPUT$()
  196. ---------------------------------------------------------------------
  197.  
  198.   In GWBASIC, there are two uses for INPUT$().
  199.   1) To fetch x number of characters from a sequential file
  200.   2) To fetch x number of characters from the keyboard
  201.  
  202.     a$ = input$(1, 10) 'Fetch 10 characters from file handle 1
  203.     a$ = input$(1) 'Fetch 1 character from the keyboard
  204.  
  205.   In Liberty BASIC, there are also two uses for INPUT$().
  206.   1) To fetch x number of characters from a sequential file
  207.   2) To fetch only 1 character from the keyboard
  208.  
  209.     a$ = input$(#1, 10) 'Fetch 10 characters from file handle #1
  210.     a$ = input$(1) 'Fetch a single character from the keyboard
  211.  
  212.  
  213. Boolean Operations
  214. ---------------------------------------------------------------------
  215.  
  216. Liberty BASIC supports AND & OR, much like GWBASIC.  These are
  217. typically used in IF...THEN statements like so:
  218.  
  219.   if x < limit and userAbort = 0 then [mainLoop]
  220.  
  221.   if (c$ >= "A" and c$ <= "Z") or (c$ >= "a" and c$ <= "z") then [inRange]
  222.  
  223. However, bitwise ANDing and ORing aren't supported.  If numbers are 
  224. ANDed or ORed, then a Zero is always a Boolean False, and any 
  225. Non-Zero is always a Boolean True, and 0 and 1 are the only possible  
  226. return values.  Consider:
  227.  
  228.   print 1 and 1         ' produces 1
  229.   print 1 and 0         ' produces 0
  230.   print 1 or 0          ' produces 1
  231.   print 0 or 23         ' produces 1
  232.   print -5 and 0        ' produces 1
  233.  
  234. GWBASIC supports bitwise operations such as:
  235.  
  236.   print 8 or 16         ' produces 24
  237.   print 7 and 15        ' produces 7
  238.  
  239. Liberty BASIC doesn't support this format.
  240.  
  241.  
  242.  
  243. TIME$(), DATE$()
  244. ---------------------------------------------------------------------
  245.  
  246. In GWBASIC you get the time or date by using the special variables
  247. time$ and date$.  For example:
  248.  
  249.   print time$           'this produces the current time
  250.   print date$           'this produces the current date
  251.  
  252. In Liberty BASIC it looks like this:
  253.  
  254.   print time$()         'this produces the current time
  255.   print date$()         'this produces the current date
  256.  
  257.  
  258.  
  259. Random Numbers
  260. ---------------------------------------------------------------------
  261.  
  262. In Liberty BASIC, random numbers between 0 and 1 are generated with
  263. the expression RND(1).  GWBASIC will produce the same result with 
  264. that expression.  Apparently GWBASIC also lets you substitute just
  265. RND, and it assumes the (1) part in this case.  Both of these lines
  266. produce the same result in GWBASIC.
  267.  
  268.   x = int(rnd(1)*10)+1  ' this format works with both BASICs
  269.   x = int(rnd*10)+1     ' this format doesn't
  270.  
  271. The second line is not permitted in Liberty BASIC.  It will always
  272. equal 1, because rnd will be parsed as a numeric variable, and will
  273. equal zero, unless it is assigned some other value.
  274.  
  275.  
  276.  
  277.