home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / BABEL2.ZIP / OPENWILD.INC < prev    next >
Encoding:
Text File  |  1993-01-01  |  3.8 KB  |  106 lines

  1. procedure hdPrint ;
  2. begin
  3.    MessageBox ( ^C'Not available in Special Edition' ,
  4.                 NIL ,
  5.                 mfInformation + mfOKButton ) ;
  6. end ;
  7.    {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  8.  
  9.    OPEN
  10.  
  11.    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  12.    {===================================================================
  13.  
  14.    OPEN - from DOS params (wildcards OK)
  15.  
  16.    ===================================================================}
  17. procedure CommandLineOpen ;
  18. var
  19.    x ,
  20.    LoadCount                 : byte ;
  21.    {-------------------------------------------------------------------
  22.    Handle Wildcards
  23.    -------------------------------------------------------------------}
  24. function OpenWildCard ( S : string ) : boolean ;
  25. var
  26.    SR                        : SearchRec ;
  27.    D                         : DirStr ;
  28.    N                         : NameStr ;
  29.    E                         : ExtStr ;
  30. begin
  31.    OpenWildCard              := FALSE ;
  32.    S                         := FExpand ( S ) ;
  33.    FSplit ( S , D , N , E ) ;
  34.    if D [ length ( D ) ] <> '\' then
  35.       D                      := D + '\' ;
  36.    FindFirst ( S , AnyFile , SR ) ;
  37.    while DosError = 0 do
  38.    begin
  39.       if ( SR.Attr and Directory = 0 ) and
  40.          ( SR.Attr and Hidden = 0 ) and
  41.          ( SR.Attr and SysFile = 0 ) and
  42.          ( SR.Attr and VolumeID = 0 ) and
  43.          ( SR.Name <> '.' ) and
  44.          ( SR.Name <> '..' ) and
  45.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  46.    COM, EXE, OVERLAY
  47.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  48.          ( pos ( '.BIN' , SR.Name ) = 0 ) and
  49.          ( pos ( '.COM' , SR.Name ) = 0 ) and
  50.          ( pos ( '.EXE' , SR.Name ) = 0 ) and
  51.          ( pos ( '.HLP' , SR.Name ) = 0 ) and
  52.          ( pos ( '.OBJ' , SR.Name ) = 0 ) and
  53.          ( pos ( '.OVL' , SR.Name ) = 0 ) and
  54.          ( pos ( '.OVR' , SR.Name ) = 0 ) and
  55.          ( pos ( '.TPU' , SR.Name ) = 0 ) and
  56.          ( pos ( '.VRM' , SR.Name ) = 0 ) and
  57.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  58.    COMPRESSED
  59.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  60.          ( pos ( '.ARC' , SR.Name ) = 0 ) and
  61.          ( pos ( '.ZIP' , SR.Name ) = 0 ) and
  62.          ( pos ( '.LZH' , SR.Name ) = 0 ) then
  63.       begin
  64.          OpenEditor ( D + SR.Name , TRUE ) ;
  65.          inc ( LoadCount ) ;
  66.       end ;
  67.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  68.    LIMIT
  69.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  70.       if LoadCount >= 16 then
  71.       begin
  72.          MessageBox ( 'Cannot auto-load more than 16 files' ,
  73.                       NIL ,
  74.                       mfInformation + mfOKbutton ) ;
  75.          EXIT ;
  76.       end ;
  77.       FindNext ( SR ) ;
  78.    end ;
  79.    OpenWildCard              := TRUE ;
  80. end ;
  81.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  82.    PROCESS
  83.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  84. begin
  85.    LoadCount                 := 0 ;
  86.    {- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  87.    MULTI-LOAD "*" or '?', OTHERWISE LOAD AS FILE
  88.    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
  89.    for x := 1 to WordCount ( ParameterString ) do
  90.    begin
  91.       if LoadCount < 16 then
  92.       begin
  93.          if ( pos ( '*' , Pluck ( ParameterString , x ) ) <> 0 ) or
  94.             ( pos ( '?' , Pluck ( ParameterString , x ) ) <> 0 ) then
  95.          begin
  96.             if not OpenWildCard ( Pluck ( ParameterString , x ) ) then EXIT ;
  97.          end
  98.          else
  99.          begin
  100.             OpenEditor ( Pluck ( ParameterString , x ) , TRUE ) ;
  101.             inc ( LoadCount ) ;
  102.          end ;
  103.       end ;
  104.    end ;
  105. end ;
  106.