home *** CD-ROM | disk | FTP | other *** search
/ Ray Tracing Box / RAY_CD.mdf / ray_util / showpic / show_pic.bas < prev    next >
BASIC Source File  |  1994-02-15  |  6KB  |  229 lines

  1. '*******************************SHOW_PIC.BAS********************************
  2. 'JRD NOTE:
  3. 'Wanted to do be able to parse a COMMAND$ since I started this in 1991
  4. '
  5. 'Also wanted to display *.PCX files without having to make 4 plane colored
  6. 'files that were 16K each.
  7. '
  8. 'Read MS Knowledge Base; recommended PICEM.EXE, a FreeWare program
  9. 'which is really impressive.
  10. '
  11. 'So this program allows you to display *.PCX files using the command syntax:
  12. '
  13. 'SHOW_PIC.COM  /t:10         /f:c:\graphics\l*.pcx
  14. '
  15. '                          
  16. 'This file    time switch    file switch
  17. '
  18. 'If you just type:
  19. '
  20. 'SHOW_PIC {Enter}
  21. '
  22. 'The program searches for PICEM.EXE in the same directory where
  23. 'SHOW_PIC.COM exists. If it finds PICEM.EXE there, it will then
  24. 'display -all- the *.PCX files in that directory for 5 seconds each.
  25. '
  26. 'If you type:
  27. '
  28. 'SHOW_PIC/?
  29. '
  30. 'You get the Help Screen and find out if PICEM.EXE is found too.
  31. '
  32. 'And.....
  33. '
  34. 'Have gotten several complaints from users of TEXT2EXE.COM, A program I
  35. 'wrote (using Ethan Winer's brains) which converts a text file to a self
  36. 'executing *.EXE file of the same name.
  37. '
  38. 'I put in a "Brag-Box" which prints to the screen:
  39. '
  40. '"Program by John De Palma on CompuServe 76076,571"
  41. '
  42. 'and flashes briefly when you exit the program.
  43. '
  44. 'Was asked to remove it by several people. One guy offered me his
  45. 'Mortuary mailing list!     Wow!!!
  46. '
  47. 'When I asked "why" they said "because." Which means (I ASSume) that they
  48. 'want their users to think they made the program. I didn't remove it -yet-
  49. 'as I need a Command Line parser such as is in this program; to make the
  50. 'display of the "Brag-Box" optional
  51. '
  52. 'This program has no Brag-Box; principally because:
  53. '
  54. '   1.  It is just a "shell" to show off PICEM.EXE, which is
  55. '        much smarter than this program.
  56. '
  57. '   2.  It is meant to be used inside batch files
  58. '       and a Brag-Box would be distracting
  59. '
  60. '   3.  I snuck in a "Copyright" string into the executable file
  61. '       which is mildly difficult to remove.
  62. '
  63. 'John De Palma on CompuServe 76076,571
  64. '
  65. '2/14/94
  66.  
  67. DEFINT A-Z
  68. '$INCLUDE: 'C:\QB45\TEST3\SHOW_PIC.BI'
  69. DECLARE SUB ComLine (Cmd$, Number, a$(), MaxParams)
  70. DECLARE SUB FileExists (FileName$, FileExist%)
  71.  
  72. 'Declarations from JOHN_SUB.BAS
  73. DECLARE SUB LocateIt (Row%, text$)
  74. DECLARE SUB ColorIt (Fgd%, Bkg%)
  75. DECLARE FUNCTION Center% (text$)
  76. DECLARE SUB CursorOff ()
  77. DECLARE SUB CursorOn ()
  78. DECLARE SUB Pause (Seconds!)
  79. DECLARE SUB ErrorBox (Row%)
  80. DECLARE SUB TextBox (Row%, Col%, Message$, Outline%, Length%)
  81. DECLARE SUB Waitkey ()
  82. DECLARE SUB WidenMsg (MsgLength%, Message$)
  83.  
  84. CONST True = -1, False = 0
  85. DIM Args$(1 TO 10)
  86.  
  87. 'Executable code starts here
  88.    
  89.     Copyright$ = "■Copyright (c) 1994 ■ John De Palma■"
  90.    
  91.     COLOR 15, 1
  92.     CLS
  93.     CursorOff
  94.    
  95.     Cmd$ = UCASE$(COMMAND$)      'need upper case
  96.     MaxArg = 10
  97.     DIM a$(1 TO MaxArg)
  98.     CALL ComLine(Cmd$, Number, a$(), MaxArg)
  99.  
  100.     ProgramName$ = "PICEM.EXE"
  101.    
  102.     FOR i = 1 TO Number
  103.        
  104.         IF INSTR(a$(i), "?") <> 0 THEN
  105.             CALL FileExists(ProgramName$, FileExist%)
  106.             GOTO Help
  107.         END IF
  108.        
  109.         IF INSTR(a$(i), "T:") <> 0 THEN
  110.             t = INSTR(a$(i), "T:")
  111.             TimeIt$ = MID$(a$(i), t + 2) + "00"
  112.         END IF
  113.        
  114.         IF INSTR(a$(i), "F:") <> 0 THEN
  115.             f = INSTR(a$(i), "F:")
  116.             FileName$ = MID$(a$(i), f + 2)
  117.         END IF
  118.     NEXT
  119.    
  120.     IF TimeIt$ = "" THEN
  121.         TimeIt$ = "500"
  122.     END IF
  123.      
  124.     IF FileName$ = "" THEN
  125.         FileName$ = "*.pcx"
  126.     END IF
  127.         
  128.     CALL FileExists(ProgramName$, FileExist%)
  129.     IF NOT FileExist% THEN GOTO Help
  130.    
  131.     'test mode to see what the command really looks like
  132.     'PRINT ProgramName$ + "/w:" + TimeIt$ + " " + FileName$ + ">nul"
  133.     'Waitkey
  134.    
  135.     SHELL ProgramName$ + "/w:" + TimeIt$ + " " + FileName$ + ">nul"
  136.     END
  137.  
  138. Help:
  139.  
  140.     Message$ = SPACE$(30)
  141.     CALL ColorIt(15, 4)
  142.     CALL TextBox(8, Col%, Message$, 5, 6)
  143.  
  144.     Message$ = "Help for SHOW_PIC.COM"
  145.     CALL WidenMsg(26, Message$)
  146.     CALL ColorIt(15, 4)
  147.     CALL LocateIt(8, Message$)
  148.  
  149.  
  150.     text$ = "/t:5    (display for 5 seconds)"
  151.     CALL ColorIt(14, 4)
  152.     CALL LocateIt(10, text$)
  153.  
  154.     text$ = "/f:Your.PCX         (file name)"
  155.     CALL LocateIt(12, text$)
  156.  
  157.     text$ = "eg: SHOW_PIC /t:5 /f:Your.PCX"
  158.     CALL ColorIt(12, 4)
  159.     CALL LocateIt(14, text$)
  160.  
  161.     IF NOT FileExist% THEN
  162.         text$ = "Can't find " + ProgramName$
  163.         CALL WidenMsg(24, text$)
  164.         CALL ColorIt(15 + 16, 0)
  165.         CALL LocateIt(16, text$)
  166.         BEEP
  167.     END IF
  168.    
  169.     Waitkey
  170.     CursorOn
  171.     CALL ColorIt(7, 0)
  172. END
  173.  
  174. SUB ComLine (Cmd$, NumArgs, Args$(), MaxArgs) STATIC
  175.    
  176.     NumArgs = 0
  177.     InSide = False
  178.    
  179.     ' Get the command line using the COMMAND$ function.
  180.     Length = LEN(Cmd$)
  181. 'STOP
  182.     ' Go through the command line a character at a time.
  183.     FOR i = 1 TO Length
  184.         C$ = MID$(Cmd$, i, 1)
  185.        
  186.         IF (C$ <> " " AND C$ <> "/" AND C$ <> "-") THEN
  187.             IF InSide = False THEN
  188.                 InSide = True
  189.                 NumArgs = NumArgs + 1
  190.             END IF
  191.             ' Add the character to the current argument.
  192.             Args$(NumArgs) = Args$(NumArgs) + C$
  193.         ELSE
  194.             InSide = False
  195.         END IF
  196.   
  197.         IF NumArgs = MaxArgs THEN EXIT FOR
  198.   
  199.     NEXT i
  200.  
  201. END SUB
  202.  
  203. 'from Ethan Winer's book; "Basic Techniques and Utilities" 1991
  204. SUB FileExists (FileName$, FileExist%)
  205.  
  206. DIM Regs AS RegType
  207.  
  208. DIM DTAData AS DTA
  209.  
  210. Spec$ = FileName$
  211.   FileExist% = -1              'assume the file exists
  212.  
  213.   Regs.dx = VARPTR(DTAData) 'set a new DOS DTA
  214.   Regs.ds = VARSEG(DTAData)
  215.   Regs.ax = &H1A00
  216.   CALL INTERRUPTX(&H21, Regs, Regs)
  217.  
  218.   Spec$ = Spec$ + CHR$(0)        'DOS needs ASCIIZ string
  219.   Regs.ax = &H4E00          'find file name service
  220.   Regs.cx = 39              'attribute for any file
  221.   Regs.dx = SADD(Spec$)     'show where the spec is
  222.   Regs.ds = VARSEG(Spec$)   'use this with QB
  223.  
  224.   CALL INTERRUPTX(&H21, Regs, Regs)
  225.   IF Regs.flags AND 1 THEN FileExist% = 0
  226.  
  227. END SUB
  228.  
  229.