home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ray Tracing Box
/
RAY_CD.mdf
/
ray_util
/
showpic
/
show_pic.bas
< prev
next >
Wrap
BASIC Source File
|
1994-02-15
|
6KB
|
229 lines
'*******************************SHOW_PIC.BAS********************************
'JRD NOTE:
'Wanted to do be able to parse a COMMAND$ since I started this in 1991
'
'Also wanted to display *.PCX files without having to make 4 plane colored
'files that were 16K each.
'
'Read MS Knowledge Base; recommended PICEM.EXE, a FreeWare program
'which is really impressive.
'
'So this program allows you to display *.PCX files using the command syntax:
'
'SHOW_PIC.COM /t:10 /f:c:\graphics\l*.pcx
'
'
'This file time switch file switch
'
'If you just type:
'
'SHOW_PIC {Enter}
'
'The program searches for PICEM.EXE in the same directory where
'SHOW_PIC.COM exists. If it finds PICEM.EXE there, it will then
'display -all- the *.PCX files in that directory for 5 seconds each.
'
'If you type:
'
'SHOW_PIC/?
'
'You get the Help Screen and find out if PICEM.EXE is found too.
'
'And.....
'
'Have gotten several complaints from users of TEXT2EXE.COM, A program I
'wrote (using Ethan Winer's brains) which converts a text file to a self
'executing *.EXE file of the same name.
'
'I put in a "Brag-Box" which prints to the screen:
'
'"Program by John De Palma on CompuServe 76076,571"
'
'and flashes briefly when you exit the program.
'
'Was asked to remove it by several people. One guy offered me his
'Mortuary mailing list! Wow!!!
'
'When I asked "why" they said "because." Which means (I ASSume) that they
'want their users to think they made the program. I didn't remove it -yet-
'as I need a Command Line parser such as is in this program; to make the
'display of the "Brag-Box" optional
'
'This program has no Brag-Box; principally because:
'
' 1. It is just a "shell" to show off PICEM.EXE, which is
' much smarter than this program.
'
' 2. It is meant to be used inside batch files
' and a Brag-Box would be distracting
'
' 3. I snuck in a "Copyright" string into the executable file
' which is mildly difficult to remove.
'
'John De Palma on CompuServe 76076,571
'
'2/14/94
DEFINT A-Z
'$INCLUDE: 'C:\QB45\TEST3\SHOW_PIC.BI'
DECLARE SUB ComLine (Cmd$, Number, a$(), MaxParams)
DECLARE SUB FileExists (FileName$, FileExist%)
'Declarations from JOHN_SUB.BAS
DECLARE SUB LocateIt (Row%, text$)
DECLARE SUB ColorIt (Fgd%, Bkg%)
DECLARE FUNCTION Center% (text$)
DECLARE SUB CursorOff ()
DECLARE SUB CursorOn ()
DECLARE SUB Pause (Seconds!)
DECLARE SUB ErrorBox (Row%)
DECLARE SUB TextBox (Row%, Col%, Message$, Outline%, Length%)
DECLARE SUB Waitkey ()
DECLARE SUB WidenMsg (MsgLength%, Message$)
CONST True = -1, False = 0
DIM Args$(1 TO 10)
'Executable code starts here
Copyright$ = "■Copyright (c) 1994 ■ John De Palma■"
COLOR 15, 1
CLS
CursorOff
Cmd$ = UCASE$(COMMAND$) 'need upper case
MaxArg = 10
DIM a$(1 TO MaxArg)
CALL ComLine(Cmd$, Number, a$(), MaxArg)
ProgramName$ = "PICEM.EXE"
FOR i = 1 TO Number
IF INSTR(a$(i), "?") <> 0 THEN
CALL FileExists(ProgramName$, FileExist%)
GOTO Help
END IF
IF INSTR(a$(i), "T:") <> 0 THEN
t = INSTR(a$(i), "T:")
TimeIt$ = MID$(a$(i), t + 2) + "00"
END IF
IF INSTR(a$(i), "F:") <> 0 THEN
f = INSTR(a$(i), "F:")
FileName$ = MID$(a$(i), f + 2)
END IF
NEXT
IF TimeIt$ = "" THEN
TimeIt$ = "500"
END IF
IF FileName$ = "" THEN
FileName$ = "*.pcx"
END IF
CALL FileExists(ProgramName$, FileExist%)
IF NOT FileExist% THEN GOTO Help
'test mode to see what the command really looks like
'PRINT ProgramName$ + "/w:" + TimeIt$ + " " + FileName$ + ">nul"
'Waitkey
SHELL ProgramName$ + "/w:" + TimeIt$ + " " + FileName$ + ">nul"
END
Help:
Message$ = SPACE$(30)
CALL ColorIt(15, 4)
CALL TextBox(8, Col%, Message$, 5, 6)
Message$ = "Help for SHOW_PIC.COM"
CALL WidenMsg(26, Message$)
CALL ColorIt(15, 4)
CALL LocateIt(8, Message$)
text$ = "/t:5 (display for 5 seconds)"
CALL ColorIt(14, 4)
CALL LocateIt(10, text$)
text$ = "/f:Your.PCX (file name)"
CALL LocateIt(12, text$)
text$ = "eg: SHOW_PIC /t:5 /f:Your.PCX"
CALL ColorIt(12, 4)
CALL LocateIt(14, text$)
IF NOT FileExist% THEN
text$ = "Can't find " + ProgramName$
CALL WidenMsg(24, text$)
CALL ColorIt(15 + 16, 0)
CALL LocateIt(16, text$)
BEEP
END IF
Waitkey
CursorOn
CALL ColorIt(7, 0)
END
SUB ComLine (Cmd$, NumArgs, Args$(), MaxArgs) STATIC
NumArgs = 0
InSide = False
' Get the command line using the COMMAND$ function.
Length = LEN(Cmd$)
'STOP
' Go through the command line a character at a time.
FOR i = 1 TO Length
C$ = MID$(Cmd$, i, 1)
IF (C$ <> " " AND C$ <> "/" AND C$ <> "-") THEN
IF InSide = False THEN
InSide = True
NumArgs = NumArgs + 1
END IF
' Add the character to the current argument.
Args$(NumArgs) = Args$(NumArgs) + C$
ELSE
InSide = False
END IF
IF NumArgs = MaxArgs THEN EXIT FOR
NEXT i
END SUB
'from Ethan Winer's book; "Basic Techniques and Utilities" 1991
SUB FileExists (FileName$, FileExist%)
DIM Regs AS RegType
DIM DTAData AS DTA
Spec$ = FileName$
FileExist% = -1 'assume the file exists
Regs.dx = VARPTR(DTAData) 'set a new DOS DTA
Regs.ds = VARSEG(DTAData)
Regs.ax = &H1A00
CALL INTERRUPTX(&H21, Regs, Regs)
Spec$ = Spec$ + CHR$(0) 'DOS needs ASCIIZ string
Regs.ax = &H4E00 'find file name service
Regs.cx = 39 'attribute for any file
Regs.dx = SADD(Spec$) 'show where the spec is
Regs.ds = VARSEG(Spec$) 'use this with QB
CALL INTERRUPTX(&H21, Regs, Regs)
IF Regs.flags AND 1 THEN FileExist% = 0
END SUB