home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / baswiz14.zip / QUESTION.TXT < prev    next >
Text File  |  1990-08-27  |  7KB  |  181 lines

  1.                       Common Questions about QuickBASIC
  2.  
  3.  
  4.  
  5. After spending much time on CompuServe, BIX, the FidoNet QuickBASIC echo and
  6. other national BASIC forums, I've noticed that there is a lot of repetition.
  7. People ask the same questions, time after time.  They must be good questions!
  8. Here is a compilation of a few of the more common questions.
  9.  
  10.  
  11.  
  12. Question:
  13.    How can I disable Control-Break?
  14.  
  15. Answer:
  16.    Programs compiled with QuickBASIC or BASCOM usually don't have to worry
  17.    about this.  Control-Break is disabled unless you compile with the /D
  18.    (debug) option.  In the event that you are doing something that QuickBASIC
  19.    doesn't completely control, like printing to the screen via DOS functions,
  20.    this protection no longer holds.  In that case, you may be able to disable
  21.    Break by getting DOS to check for it less frequently.  Use the command
  22.       BREAK OFF
  23.    from a batch file, or execute it from BASIC like so:
  24.       SHELL "COMMAND BREAK OFF"
  25.  
  26.  
  27.  
  28. Question:
  29.    How can I get the error level from a SHELLed program?  How can I get my
  30.    program to return an error level?
  31.  
  32. Answer:
  33.    You can't.  More accurately, you can only do it with assembly language
  34.    routines.  I'll add that capability to a later version of BASWIZ.
  35.  
  36.  
  37.  
  38. Question:
  39.    How can I get access to COM3 and COM4 for my communications program?
  40.  
  41. Answer:
  42.    You can't do that with BASIC alone, but BASWIZ will let you do it.  Check
  43.    the BASWIZ.DOC manual and TERM.BAS example program.
  44.  
  45. Question:
  46.    How can I get a directory listing into an array?
  47.  
  48. Answer:
  49.    Most BASIC libraries can do this for you.  Another way to do this is to
  50.    put the directory listing into a file by
  51.       SHELL "COMMAND DIR *.* >DIRLIST.TXT"
  52.    and then read the file into an array.  Yet another alternative is to use
  53.    the FILES statement on a non-displayed screen page (if you have a CGA, EGA
  54.    or VGA) or in invisible colors (say, black on black), then get the results
  55.    off the screen with the SCREEN function.
  56.  
  57.  
  58.  
  59. Question:
  60.    How can I see if a file exists?
  61.  
  62. Answer:
  63.    Most BASIC libraries can do this for you.  Or, you can use the directory
  64.    approach given above.  Yet another way to do it is to try to open the file
  65.    for input:
  66.  
  67.          ON ERROR GOTO NotFound
  68.          OPEN File$ FOR INPUT AS #1
  69.          CLOSE #1
  70.          Found = -1
  71.       Done:
  72.          RETURN
  73.       NotFound:
  74.          Found = 0
  75.          RESUME Done
  76.  
  77.  
  78.  
  79. Question:
  80.    I'm running out of string space.  What can I do?
  81.  
  82. Answer:
  83.    If you have arrays, try moving them outside of the string space area.
  84.    Either use REDIM to dimension 'em or use the REM $DYNAMIC metacommand.  If
  85.    this doesn't help enough, use fixed-length strings, which are stored
  86.    outside the regular string area.  Still not enough room?  Well, you can
  87.    buy Microsoft's BASCOM 7.0 "Professional Development System", which will
  88.    set you back about $300.  Or, you can simply use the "far string" routines
  89.    provided in BASWIZ.  See the BASWIZ.DOC manual for details.
  90.  
  91. Question:
  92.    I'd like to constantly display the time.  What do I do?
  93.  
  94. Answer:
  95.    That's also available in libraries (gee, aren't libraries great?!).  You
  96.    can do it yourself using an approach like this:
  97.  
  98.          ON TIMER(1) GOSUB DisplayTime
  99.          TIMER ON
  100.          ' your program goes here
  101.       DisplayTime:
  102.          OldRow = CSRLIN
  103.          OldCol = POS(0)
  104.          LOCATE 25, 70
  105.          PRINT TIME$;
  106.          LOCATE OldRow, OldCol
  107.          RETURN
  108.  
  109.  
  110.  
  111. Question:
  112.    I need to know how many days lie in between two dates.  How do I do it?
  113.  
  114. Answer:
  115.    As usual... this is something you can get in a library from your local
  116.    BBS.  Try QB4BAS.  It's quite possible to do it in BASIC, but I can never
  117.    remember the proper formulae... you need to account for leap years and
  118.    leap centuries, so it isn't as straightforward as you might guess.
  119.  
  120.  
  121.  
  122. Question:
  123.    How can I use ANSI display codes?
  124.  
  125. Answer:
  126.    You need to go through DOS display functions for that to work.  Use this:
  127.       OPEN "CON" FOR OUTPUT AS #1
  128.    This makes the DOS display functions available as file (device) number
  129.    one.  You can print to it using normal file statements:
  130.       PRINT #1, CHR$(27); "[2J";
  131.    The above statement will clear the screen if an ANSI driver is installed.
  132.    See your DOS manual for information on the available ANSI codes.  You can
  133.    also get this information from your friendly local BBS.
  134.  
  135.    If you are using the BASWIZ library, check out ANSIprint in the
  136.    "Telecommunications" section.  It handles ANSI in a virtual window and
  137.    also allows for "ANSI" music processing if desired.  ANSI.SYS not needed.
  138.  
  139. Question:
  140.    How can I print the screen to the printer, in text or graphics mode?
  141.  
  142. Answer:
  143.    One simple solution is to use CALL INTERRUPT.  Interrupt number 5 (five)
  144.    does the same thing as pressing PrintScreen/PrtSc on your keyboard.  It
  145.    will handle CGA graphics as well as text mode if GRAPHICS is installed
  146.    (GRAPHICS.COM or GRAPHICS.EXE is provided with DOS).
  147.  
  148.    If you are just using text mode, check into the SCREEN function, which
  149.    allows you to read characters off the display.  If you collect each row
  150.    into a string and then use RTRIM$ to remove trailing blanks, it'll be
  151.    faster.
  152.  
  153.    My GRAFWZ library also provides a PrintScreen routine which will work on
  154.    virtually any text or graphics mode, given an Epson-compatible printer.
  155.    You can find GRAFWZ at your local BBS.
  156.  
  157.  
  158.  
  159. Question:
  160.    How can I display picture files, like GIF, PCX, MAC, MSP and so forth?
  161.  
  162. Answer:
  163.    Well, the GRAFWZ library can help a bit with MAC files.  Probably the best
  164.    solution for a general-purpose picture handler, though, would be to get a
  165.    copy of OPTIKS (usually distributed as OK followed by a version number) or
  166.    another picture format converter at your local BBS.  Image translation
  167.    tends to be somewhat difficult and slow in BASIC, and it's hard to find
  168.    the information needed to handle the various formats available.  If you
  169.    can read other languages than BASIC, you can find source code for various
  170.    picture handlers on your local BBS.  These are often written in assembly
  171.    language, C, and Pascal, which are better for this specific purpose than
  172.    BASIC.
  173.  
  174.  
  175.  
  176. Have I mentioned BBSes a lot?!  If you don't have a modem, make the
  177. investment!  It will be well worth it, whether you are a serious programmer
  178. or just like to fiddle around now and then.  There are vast numbers of files
  179. and helpful people within reach of a telephone call of your computer!
  180.  
  181.