Need a routine

 BBS: Inland Empire Archive
Date: 04-04-93 (19:38)             Number: 252
From: KEN PREVO                    Refer#: NONE
  To: JOE NEGRON                    Recvd: NO  
Subj: Need a routine                 Conf: (2) Quik_Bas
Here's the function you need and one for good measure-old BASNet posting
<g>

This version is for PowerBASIC.  The QB one is much larger and far less
elegant:
    Call Interrupt is a part of the language--no qlb needed.
    REGs is a builtin and In/Out copies aren't required.
    Unsigned integers and PEEKI allow referencing more data from
      memory than a single byte.
    PEEK$ allows block copies --although a union might have been
      more elegant and not required copying the data into program
      space

DEFINT A-Z

DECLARE FUNCTION CmdLine$ ()
DECLARE FUNCTION ProgName$ ()

PRINT
PRINT "This program was loaded as '"; ProgName$;"'"
IF LEN(CmdLine$) THEN PRINT "With a command line of '"; CmdLine$;"'"

FUNCTION CmdLine$  'return the original, mixed case command line.
   REG 1, &H5100  'ax
   CALL Interrupt &H21
   Segment?? = REG(2) 'bx
   DEF SEG = Segment??
   Temp$ = PEEK$(&H81, PEEK(&H80))
   DEF SEG
   CmdLine$ = Temp$
'  You may want:  RTRIM$(Temp$), Chr$(0)+Chr$(32)+CHR$(255)+CHR$(8))
                 'in case there's are some strange user artifacts
END FUNCTION

FUNCTION ProgName$ 'fetch the program's full-path and name
   REG 1, &H6200
   CALL Interrupt &H21
   DEF SEG = REG(2) 'BX register held segment location.

   EnvBlkSeg?? = PEEKI(&H2C)
   DEF SEG = EnvBlkSeg??
   Temp$ = PEEK$(8, 47) '8 bypasses 'COMSPEC=' and 42 is the max len
                        'dos allows for a path(32)+file(13)+drive(2)
   DEF SEG
   ProgName$ = left$(Temp$,INSTR(Temp$,Chr$(0))-1) 'only the part to the nul
END FUNCTION
  SLMR 2.0 
  BASNet: NetHost- The Toolkit BBS, Lowell,IN (219)696-3415


--- WM v2.08/91-0012
 * Origin: Com-Dat BBS  Hillsboro, OR.  HST (503) 681-0543 (1:105/314)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET