home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / basic / baswiz18.zip / QUESTION.TXT < prev    next >
Text File  |  1991-11-17  |  7KB  |  192 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.    You may also wish to try the BreakOff routine in my PBClone library.
  27.  
  28.  
  29.  
  30. Question:
  31.    How can I get the error level from a SHELLed program?  How can I get my
  32.    program to return an error level?
  33.  
  34. Answer:
  35.    That requires assembly language.  My PBClone library contains such
  36.    routines.  I believe the QB4BAS library also has those capabilities.
  37.  
  38.  
  39.  
  40. Question:
  41.    How can I read the command line from BASIC?
  42.  
  43. Answer:
  44.    The COMMAND$ function will do it for you.  Note that COMMAND$ doesn't
  45.    return the exact command line-- it is trimmed somewhat and capitalized.
  46.  
  47.  
  48.  
  49. Question:
  50.    How can I get access to COM3 and COM4 for my communications program?
  51.  
  52. Answer:
  53.    BASIC doesn't provide support for those comm ports.  However, there are
  54.    many add-on libraries which will let you do it.  Look for BasWiz, QBCOM,
  55.    or QBSER, among others.
  56.  
  57. Question:
  58.    How can I get a directory listing into an array?
  59.  
  60. Answer:
  61.    Most BASIC libraries can do this for you.  Another way to do this is to
  62.    put the directory listing into a file by
  63.       SHELL "DIR *.* >DIRLIST.TXT"
  64.    and then read the file into an array.  Yet another alternative is to use
  65.    the FILES statement on a non-displayed screen page (if you have a CGA, EGA
  66.    or VGA) or in invisible colors (say, black on black), then get the results
  67.    from the screen with the SCREEN function.
  68.  
  69.  
  70.  
  71. Question:
  72.    How can I see if a file exists?
  73.  
  74. Answer:
  75.    Most BASIC libraries can do this for you.  Or, you can use the directory
  76.    approach given above.  Yet another way to do it is to try to open the file
  77.    for input:
  78.  
  79.          ON ERROR GOTO NotFound
  80.          OPEN File$ FOR INPUT AS #1
  81.          CLOSE #1
  82.          Found = -1
  83.       Done:
  84.          RETURN
  85.       NotFound:
  86.          Found = 0
  87.          RESUME Done
  88.  
  89.  
  90.  
  91. Question:
  92.    I'm running out of string space.  What can I do?
  93.  
  94. Answer:
  95.    If you have arrays, try moving them outside of the string space area.
  96.    Either use REDIM to dimension 'em or use the REM $DYNAMIC metacommand.  If
  97.    this doesn't help enough, use fixed-length strings, which are stored
  98.    outside the regular string area.  Still not enough room?  Well, you can
  99.    buy Microsoft's BASCOM 7.x "Professional Development System", which will
  100.    set you back about $300.  Or, you can simply use the "far string" routines
  101.    provided in my BasWiz library.
  102.  
  103. Question:
  104.    I'd like to constantly display the time.  What do I do?
  105.  
  106. Answer:
  107.    That's also available in libraries, including PBClone.  You can do it
  108.    yourself using an approach like this, among other ways:
  109.  
  110.          ON TIMER(1) GOSUB DisplayTime
  111.          TIMER ON
  112.          ' your program goes here
  113.       DisplayTime:
  114.          OldRow = CSRLIN
  115.          OldCol = POS(0)
  116.          LOCATE 25, 70
  117.          PRINT TIME$;
  118.          LOCATE OldRow, OldCol
  119.          RETURN
  120.  
  121.  
  122.  
  123. Question:
  124.    I need to know how many days lie in between two dates.  How do I do it?
  125.  
  126. Answer:
  127.    As usual... this is something you can get in a library from your local
  128.    BBS.  Try QB4BAS.  It's quite possible to do it in BASIC, but I can never
  129.    remember the proper formulae... you need to account for leap years and
  130.    leap centuries, so it isn't as straightforward as you might guess.
  131.  
  132.  
  133.  
  134. Question:
  135.    How can I use ANSI display codes?
  136.  
  137. Answer:
  138.    You need to go through DOS display functions for that to work.  Use this:
  139.       OPEN "CON" FOR OUTPUT AS #1
  140.    This makes the DOS display functions available as file (device) number
  141.    one.  You can print to it using normal file statements:
  142.       PRINT #1, CHR$(27); "[2J";
  143.    The above statement will clear the screen if an ANSI driver is installed.
  144.    See your DOS manual for information on the available ANSI codes.  You can
  145.    also get this information from your friendly local BBS.
  146.  
  147.    If you are using the BasWiz library, check out ANSIprint in the
  148.    Telecommunications section.  It handles ANSI in a virtual window and also
  149.    allows for "ANSI" music processing if desired.  ANSI.SYS not needed.
  150.  
  151. Question:
  152.    How can I print the screen to the printer, in text or graphics mode?
  153.  
  154. Answer:
  155.    One simple solution is to use CALL INTERRUPT.  Interrupt number 5 (five)
  156.    does the same thing as pressing PrintScreen/PrtSc on your keyboard.  It
  157.    will handle CGA graphics as well as text mode if GRAPHICS is installed
  158.    (GRAPHICS.COM or GRAPHICS.EXE is provided with DOS).
  159.  
  160.    If you are just using text mode, check into the SCREEN function, which
  161.    allows you to read characters off the display.  If you collect each row
  162.    into a string and then use RTRIM$ to remove trailing blanks, it'll be
  163.    faster than sending all those meaningless blanks to the printer.
  164.  
  165.    My BasWiz library also provides a PrintScreen routine which will work on
  166.    virtually any text or graphics mode, given an Epson-compatible printer.
  167.  
  168.  
  169.  
  170. Question:
  171.    How can I display picture files, like GIF, PCX, MAC, MSP and so forth?
  172.  
  173. Answer:
  174.    Well, the BasWiz library can help with MAC and PCX files.  Probably the
  175.    best solution for a general-purpose picture handler, though, would be to
  176.    get a copy of OPTIKS (usually distributed as OK followed by a version
  177.    number) or another picture format converter at your local BBS.  Image
  178.    translation tends to be somewhat difficult and slow in BASIC, and it's
  179.    hard to find the information needed to handle the various formats
  180.    available.  If you can read other languages than BASIC, you can find
  181.    source code for various picture handlers on your local BBS.  These are
  182.    often written in assembly language, C, and Pascal, which are better for
  183.    this specific purpose than BASIC.
  184.  
  185.  
  186.  
  187. Have I mentioned BBSes a lot?!  If you don't have a modem, make the
  188. investment!  It will be well worth it, whether you are a serious programmer
  189. or just like to fiddle around now and then.  There are vast numbers of files
  190. and helpful people within reach of a telephone call of your computer!
  191.  
  192.