BCX Console Demonstration Program s105.bas

DIM Arg$
DIM F$

Arg$ = COMMAND$

IF Arg$ = "" THEN
  COLOR 7, 0
  CLS
  PRINT "-----------------------------------------------------------------"
  COLOR 2, 0
  PRINT "PickFile 1.0 by Kevin Diggins ( 32 bit Freeware ) For Win95/98/NT"
  COLOR 7, 0
  PRINT "-----------------------------------------------------------------"
  PRINT "PickFile provides commandline users with a Windows File Dialog"
  PRINT "from which to choose and then pass on the selected filename to "
  PRINT "the program specified on the command line by the user."
  PRINT "-----------------------------------------------------------------"
  COLOR 2, 0
  PRINT "For Example:    PickFile C:\Windows\Command\EDIT"
  COLOR 7, 0
  PRINT "takes the file chosen from the Windows File Dialog and then"
  PRINT "passes it to EDIT, which is a simple MSDOS text editor."
  PRINT "-----------------------------------------------------------------"
  END
END IF

F$ = "*.*"

OpenFileDialog(0, "PickFile v1.0 by Kevin Diggins", F$, "", "All", "*.*", 0)

IF F$ <> "*.*" THEN
  Arg$ = Arg$ & " " & F$
  SHELL Arg$
END IF

FUNCTION OpenFileDialog _
   (                  _
   HndlWnd AS HWND     , _
   zCaption$         , _
   zFilespec$        , _
   zInitialDir$      , _
   zFilter$          , _
   zDefExtension$    , _
   Flags               _
   )

  LOCAL ofn AS OPENFILENAME
  LOCAL File$
  LOCAL FileTitle$
  LOCAL Filter$
  LOCAL InitialDir$
  LOCAL Title$
  LOCAL DefExt$
  LOCAL RetFlg

  IF LEN(zInitialDir$) = 0 THEN
    InitialDir$ = CURDIR$
  END IF

  Filter$             = zFilter$
  InitialDir$         = zInitialDir$
  File$               = zFilespec$
  DefExt$             = zDefExtension$
  Title$              = zCaption$

  ofn.lStructSize     = SIZEOF(ofn)
  ofn.hwndOwner       = HndlWnd
  ofn.lpstrFilter     = Filter$
  ofn.nFilterIndex    = 1
  ofn.lpstrFile       = File$
  ofn.nMaxFile        = SIZEOF(File$)
  ofn.lpstrFileTitle  = FileTitle$
  ofn.nMaxFileTitle   = SIZEOF(FileTitle$)
  ofn.lpstrInitialDir = InitialDir$
  ofn.Flags           = Flags
  ofn.lpstrDefExt     = DefExt$

  IF LEN(Title$) > 0 THEN
    ofn.lpstrTitle = Title$
  END IF

  RetFlg = GetOpenFileName(&ofn)

  zFilespec$ = File$
  Flags = ofn.Flags
  FUNCTION = RetFlg
END FUNCTION

Result:

Result not displayed for this example.