home *** CD-ROM | disk | FTP | other *** search
- '******************************NAMETRUE.BAS*****************************
- '
- 'JRD NOTE:
- '
- 'Another little known gem. The Undocumented MS-DOS command TRUENAME!
- '
- 'If you enter a VALID file name =OF ANY KIND=, it returns that name
- 'and the PATH where you entered the name.
- '
- 'If you try to find out what its internal help switches are by typing:
- 'TRUENAME/? {Enter}
- '
- 'DOS says: "Reserved command name"
- '
- 'But that's OK, this program allows you to screen for =all= (I think) the
- 'illegal characters that a person may enter, and you can check them
- 'out one by one with this program.
- '
- 'Doesn't give you an error with the forward slash "/" or ".?/*" with
- 'this program using just TRUENAME, but "/" definitely will if you
- 'invoke TRUENAME from the command line.
-
- 'I trapped: InValid$ = "\/?*" in the NameTrue$(InSpec$) FUNCTION
- 'because though they are LEGAL PATH names, they are ILLEGAL file Names
- '
- 'Otherwise TRUENAME as used in this program does trap "all" the other
- 'Illegal names... TRUENAME is terrific!
- '
- 'As you enter all kinds of keys, remember that if the DRIVE is
- 'invalid, that will give a PATH error, that is NOT an illegal name!
- 'That's why I displayed the MS-DOS Error Codes.
- '
- 'TRUENAME doesn't care if the PATH DOESN'T EXIST, just as long as it
- 'COULD be a VALID PATH or FileName!
-
- 'Test it out, you will surprised how effective and "smart" TRUENAME is.
- '
- '4/9/94
- '
- '
- ' $INCLUDE: 'QB.BI'
- DECLARE FUNCTION NameTrue$ (InSpec$)
- DIM SHARED Regs AS RegType
-
- 'declares from JOHN_SUB.BAS
- DECLARE FUNCTION BufferedKeyInput$ (n%)
- DECLARE FUNCTION Center% (text$)
- DECLARE SUB ColorIt (Fgd%, Bkg%)
- DECLARE SUB CursorOff ()
- DECLARE SUB CursorOn ()
- DECLARE SUB LocateIt (Row%, text$)
- DECLARE SUB WaitKey ()
- DECLARE SUB TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- DECLARE SUB Splash (BackGround%)
- DECLARE SUB ErrorHandler (ErrorCode%)
- DECLARE SUB GetColr (Fgd%, Bkg%, Colr%)
- DECLARE SUB TwoColrs (Fgd%, Bkg%, Colr%)
- DECLARE SUB SetBorder (ColrByte%)
-
- REDIM SHARED Box$(1 TO 56)
-
-
- 'executable code follows
- Copyright$ = "■Copyright (c) 1994 LearnWare (c) ■ John De Palma■"
- Again:
- CursorOff
- CALL ColorIt(7, 1)
- CLS
- CALL SetBorder(4)
- Splash (177)
- Message$ = "Use the TRUENAME Undocumented MS-DOS Command"
- CALL ColorIt(14, 4)
- CALL TextBoxShadow(2, 0, Message$, 4, 1, 0)
- CALL ColorIt(15, 1)
- d$ = DATE$
- t$ = TIME$
- Length% = LEN(t$) + 2
- Buffer$ = SPACE$(10)
- Message$ = SPACE$(Length%)
- CALL ColorIt(11, 3)
- CALL TextBoxShadow(15, 4, Message$, 4, 1, 1)
- RSET Buffer$ = d$
- LOCATE 16, 7: PRINT Buffer$
- RSET Buffer$ = t$
- LOCATE 17, 7: PRINT Buffer$
- CALL ColorIt(15, 1)
- text$ = " TYPE: a FILE NAME, Legal -or- illegal "
- Message$ = SPACE$(LEN(text$))
- CALL TextBoxShadow(7, 0, Message$, 5, 0, 0)
-
-
- CALL LocateIt(7, text$)
-
- CALL ColorIt(11, 0)
- text$ = SPACE$(13)
- CALL LocateIt(8, text$)
- LOCATE 8, Center%(text$)
- CursorOn
-
- InSpec$ = BufferedKeyInput(13)
- CursorOff
- CALL ColorIt(15, 1)
- OutSpec$ = NameTrue$(InSpec$)
- IF LEN(OutSpec$) THEN
- Message$ = "A legal Name: " + OutSpec$
- CALL TextBoxShadow(12, 0, Message$, 5, 1, 0)
- CALL ColorIt(15, 7)
- Message$ = "PRESS a Key to Try another Name or <Esc> to EXIT"
- CALL TextBoxShadow(18, 0, Message$, 3, 0, 0)
- WaitKey
- GOTO Again
- END IF
- CALL ColorIt(11, 0)
- Message$ = "PRESS a Key to Try another Name or <Esc> to EXIT"
- CALL TextBoxShadow(14, 0, Message$, 6, 0, 0)
- WaitKey
- GOTO Again
-
- DEFINT A-Z
- FUNCTION BufferedKeyInput$ (n%) STATIC
-
- 'DIM Regs AS RegType
- b$ = CHR$(n% + 1) + SPACE$(n% + 1) + CHR$(13) 'see EXPLANATION
-
- Regs.ax = &HA00 'BufferkeyInput MS-DOS Function
- Regs.ds = VARSEG(b$) 'segment of string b$
- Regs.dx = SADD(b$) 'offset of string b$
- 'using qb.bi INCLUDE file
- CALL INTERRUPTX(&H21, Regs, Regs)
- count% = ASC(MID$(b$, 2, 1)) 'length of the string b$
-
- 'EXPLANATION of b$ command
- 'byte one of b$ contains the working -size- of the string.
- 'byte two is the -actual size- of the string that MS-DOS uses.
- 'last byte is a carriage return which is needed to prevent
- 'a STRING SPACE CORRUPT Run Time error when you use this
- 'so the return string starts at byte three (3), and does NOT
- 'include the carriage return
- 'see below
- BufferedKeyInput$ = MID$(b$, 3, count%)
-
- END FUNCTION
-
- FUNCTION Center% (text$)
- Center% = 41 - LEN(text$) \ 2
- END FUNCTION
-
- SUB ColorIt (Fgd, Bkg)
- COLOR Fgd, Bkg
- END SUB
-
- SUB CursorOff
- LOCATE , , 0
- END SUB
-
- SUB CursorOn
- LOCATE , , 1, 4, 7
- END SUB
-
- SUB ErrorHandler (ErrorCode%)
-
- 'This will trap all INTERRUPT &H21 error codes placed in AX
- 'for FUNCTION &H5A and &H3E
- 'Well... actually -all- INTERRUPT &H21 Functions use these error codes
- 'as defined and trapped in the MakeTempFile SUB
- '
- CALL GetColr(Fgd%, Bkg%, Colr%) 'saves the screen color
-
- SELECT CASE ErrorCode%
-
- CASE 0
- text$ = "No ERROR FOUND: " + LTRIM$(STR$(ErrorCode%))
- CASE 2
- text$ = "ILLEGAL NAME!!! ERROR # " + LTRIM$(STR$(ErrorCode%))
- CASE 3
- text$ = "PATH Not FOUND! ERROR # " + LTRIM$(STR$(ErrorCode%))
- CASE 4
- text$ = "Too Many Open Files! ERROR # " + LTRIM$(STR$(ErrorCode%))
- CASE 5
- text$ = "Access Denied, Read only File! ERROR # " + LTRIM$(STR$(ErrorCode%))
- CASE 1, 6 TO 18
- 'are defined, but easier to look up in a book,
- 'page 418, Norton's 1993 PC Programmer's Bible...
- text$ = "Weird Error, Write it Down! ERROR # " + LTRIM$(STR$(ErrorCode%))
- CASE ELSE
- text$ = "Undefined Error, Write it Down, ERROR # " + LTRIM$(STR$(ErrorCode%))
- END SELECT
-
- IF ErrorCode% > 0 THEN BEEP
-
- COLOR 14, 4
- CALL TextBoxShadow(20, 0, text$, 1, 1, 0)
- COLOR Fgd%, Bkg%
- END SUB
-
- SUB GetColr (Fgd%, Bkg%, Colr%) STATIC
-
- Colr% = SCREEN(1, 1, 1)
-
- Fgd% = (Colr% AND 128) \ 8 + (Colr% AND 15)
- Bkg% = (Colr% AND 112) \ 16
-
- END SUB
-
- SUB LocateIt (Row%, text$)
- LOCATE Row%, Center(text$)
- PRINT text$;
- END SUB
-
- FUNCTION NameTrue$ (InSpec$)
-
- 'DIM Regs AS RegType
- DIM InString AS STRING * 128
- DIM OutString AS STRING * 128
-
-
-
- InValid$ = " \/?*" 'TRUENAME gets the rest, except..
- Length% = LEN(InValid$)
- FOR i = 1 TO Length%
- IF INSTR(InSpec$, MID$(InValid$, i, 1)) THEN
- ErrorCode% = 2
- CALL ErrorHandler(ErrorCode%)
- EXIT FUNCTION
- END IF
- NEXT
- Dots$ = ".." 'the one and two beginning dots
- FOR i = 1 TO 2
- IF INSTR(MID$(Dots$, 1, i), InSpec$) THEN
- ErrorCode% = 2
- CALL ErrorHandler(ErrorCode%)
- EXIT FUNCTION
- END IF
- NEXT
-
- InString = InSpec$ + CHR$(0) ' make an ASCIIZ version of input spec
- Regs.ax = &H6000 ' invoke the TRUENAME DOS function
- Regs.si = VARPTR(InString)
- Regs.di = VARPTR(OutString)
- CALL INTERRUPT(&H21, Regs, Regs)
-
- 'Check for DOS error, if so, return no name
- IF Regs.flags AND 1 THEN
-
- ErrorCode% = Regs.ax 'Error Code in AX
- IF ErrorCode% THEN CALL ErrorHandler(ErrorCode%)
- EXIT FUNCTION
- ELSE
- NameTrue$ = MID$(OutString, 1, INSTR(OutString, CHR$(0)) - 1)
- END IF
- END FUNCTION
-
- SUB SetBorder (ColrByte%) STATIC
-
- 'DIM Regs AS RegType
- Regs.ax = &H1001
- Regs.bx = ColrByte% * &H100
- CALL INTERRUPT(&H10, Regs, Regs)
-
- END SUB
-
- SUB Splash (BackGround%) STATIC
- STATIC ColrFlag%
- RANDOMIZE TIMER
- IF ColrFlag% AND BackGround% THEN
- UpperBound = 254
- LowerBound = 176
- Char = INT((UpperBound - LowerBound + 1) * RND + LowerBound)
- ELSEIF BackGround% THEN
- Char = BackGround%
- ELSE
- Char = 176
- END IF
- CLS
- FOR i = 1 TO 25
- LOCATE i, 1
- PRINT STRING$(80, Char);
- NEXT
- ColrFlag% = True
- END SUB
-
- SUB TextBoxShadow (Row%, Col%, Message$, Outline%, Shadow%, Length%)
- 'Will put a message into a three line box -or-
- 'draw a box without a message using Message$=SPACE$(x)
- 'where "x" is the width of the box and Length%= number of lines > 3
- 'Boxes are centered if Col% = 0; else left side of box = Col%.
- 'Boxes display a true shadow if Shadow% <> 0
- 'True = -1: False = 0
-
- STATIC BoxReadFlag
- Message$ = LEFT$(Message$, 60)
- BoxWidth% = LEN(Message$) + 4
- SELECT CASE Outline%
- CASE 0
- j = 8 * 6 + 1
- CASE 1
- j = 1
- CASE 2
- j = 8 + 1
- CASE 3
- j = 8 * 2 + 1
- CASE 4
- j = 8 * 3 + 1
- CASE 5
- j = 8 * 4 + 1
- CASE 6
- j = 8 * 5 + 1
- CASE ELSE
- j = 8 * 6 + 1
- END SELECT
-
- IF BoxReadFlag THEN GOTO Skip
- REDIM Box$(1 TO 56)
- BoxReadFlag = True
-
- 'single line box
- Box$(1) = "┌"
- Box$(2) = "─"
- Box$(3) = "┐"
- Box$(4) = "│"
- Box$(5) = "│"
- Box$(6) = "└"
- Box$(7) = "─"
- Box$(8) = "┘"
-
- 'double top box
- Box$(9) = "╒"
- Box$(10) = "═"
- Box$(11) = "╕"
- Box$(12) = "│"
- Box$(13) = "│"
- Box$(14) = "╘"
- Box$(15) = "═"
- Box$(16) = "╛"
-
- 'double side box
- Box$(17) = "╓"
- Box$(18) = "─"
- Box$(19) = "╖"
- Box$(20) = "║"
- Box$(21) = "║"
- Box$(22) = "╙"
- Box$(23) = "─"
- Box$(24) = "╜"
-
- 'double box
- Box$(25) = "╔"
- Box$(26) = "═"
- Box$(27) = "╗"
- Box$(28) = "║"
- Box$(29) = "║"
- Box$(30) = "╚"
- Box$(31) = "═"
- Box$(32) = "╝"
-
- 'bold box
- Box$(33) = "█"
- Box$(34) = "▀"
- Box$(35) = "█"
- Box$(36) = "█"
- Box$(37) = "█"
- Box$(38) = "█"
- Box$(39) = "▄"
- Box$(40) = "█"
-
- 'bold and thick box
- Box$(41) = "█"
- Box$(42) = "█"
- Box$(43) = "█"
- Box$(44) = "█"
- Box$(45) = "█"
- Box$(46) = "█"
- Box$(47) = "█"
- Box$(48) = "█"
-
- 'no box
- Box$(49) = " "
- Box$(50) = " "
- Box$(51) = " "
- Box$(52) = " "
- Box$(53) = " "
- Box$(54) = " "
- Box$(55) = " "
- Box$(56) = " "
-
- Skip:
-
- IF Col% = 0 THEN
-
- BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
- CALL LocateIt(Row%, BoxText$)
- Row2% = CSRLIN: Col2% = POS(0)
- Colr% = SCREEN(Row2%, Col2% - 1, 1)
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
-
- FOR i = 1 TO Length% + 1
- BoxText$ = Box$(j + 3) + " " + Message$ + " " + Box$(j + 4)
- CALL LocateIt(Row% + i, BoxText$)
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
- NEXT i
-
- BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
- CALL LocateIt(Row% + i, BoxText$)
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- 'COLOR Fgd%, Bkg%
-
- COLOR 7, 0
- LOCATE Row% + i + 1, Center(BoxText$) + 2
-
- FOR k = 1 TO BoxWidth% + 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
- ELSE
-
- BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
- LOCATE Row%, Col%
- PRINT BoxText$;
- Row2% = CSRLIN: Col2% = POS(0)
- Colr% = SCREEN(Row2%, Col2% - 1, 1)
- CALL TwoColrs(Fgd%, Bkg%, Colr%)
-
- FOR i = 1 TO Length% + 1
- BoxText$ = Box$(j + 3) + " " + Message$ + " " + Box$(j + 4)
- LOCATE Row% + i, Col%
- PRINT BoxText$;
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
-
- NEXT i
-
- BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
- LOCATE Row% + i, Col%
- PRINT BoxText$;
-
- IF Shadow% THEN
- COLOR 7, 0
- FOR k = 1 TO 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- 'COLOR Fgd%, Bkg%
- 'COLOR 7,0
- LOCATE Row% + i + 1, Col% + 2
- FOR k = 1 TO BoxWidth% + 2
- PRINT CHR$(SCREEN(CSRLIN, POS(0)));
- NEXT
- COLOR Fgd%, Bkg%
- END IF
-
- END IF
-
- END SUB
-
- SUB TwoColrs (Fgd%, Bkg%, Colr%)
-
- Fgd% = (Colr% AND 128) \ 8 + (Colr% AND 15)
- Bkg% = (Colr% AND 112) \ 16
-
- END SUB
-
- SUB WaitKey
-
- WHILE INKEY$ <> "": WEND
- DO
- kee$ = INKEY$
- LOOP UNTIL LEN(kee$)
- IF kee$ = CHR$(27) THEN
- CALL SetBorder(0)
- END
- END IF
- END SUB
-
-