Re: DIR() function in XP

new topic     » topic index » view thread      » older message » newer message

Sergio Gelli wrote:
> 
> Al Getz wrote:
> > 
> > Sergio Gelli wrote:
> > > 
> > > 
> > > Hi Al
> > > 
> > > Como está você? Grande prazer em falar contigo!
> > > 
> > > Which the reason to continue using .ex?  I am old 
> > > dinossauro (in extinguishing :))  Really, the reason is that 
> > > in our business we use a system with old Dbase-4 and there 
> > > exists more than 3000 programs twirling.  Is to hard chang it.
> > > We use the Euphoria to help the Dbase in some works, for 
> > > example: back-ups. 
> > > 
> > > Boa sorte para você também!
> > > 
> > > Sérgio Gelli - Brasil
> > 
> > 
> > Ola outra vez Sergio,
> > 
> > Muito bom, obrigado, e o prazer e meu ingualmente.
> > Eu aprecio sempre falar com o alguem de Brasil!
> > 
> > I guess you know your software better than i do, but if you are
> > just doing some file detection and copying you could probably
> > use the exw form as well as the ex form, unless of course you
> > have some DOS specific stuff you need.  Maybe you could make
> > a list of all the Euphoria functions you call and post them 
> > here and we can try to determine if you can make the move
> > to the exw form in order to make things run a bit smoother.
> > Another idea would be to create another exe program you can
> > call from your .ex program to get the 'dir' of a given
> > directory and store the results in a text file.  Your .ex
> > file could then read the text file to get the results.
> > I used to do this with an old program of mine until converting
> > to using Window's API function calls.
> > 
> > 
> > Ate logo,
> > Al
> > 
> > E boa sorte com sua programação Euphoria!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> 
> Hi All
> 
> Bom dia! Obrigado pela atenção.
> 
> It will be that the MSDOS goes to finish?  
> I am sad for knowing that Euphoria will not have resources 
> to make a simple work same as it makes the function to dir (), 
> perhaps, with the progress of the Windows platform, more 
> functions will leave to work.  But perhaps, either only 
> setings of my XP that is incorrect.  This is very probable 
> because our Dbase IV, made in 1993 is working without imperfections.  
> I will be in these days, trying to migrate for .exw. 
> 
> its ideia to create an archive of text with the directory 
> information, certainly goes to work, because in my project 
> this is made accurately in this way, one procedure lists all 
> folders, sub-folders and archives. You it would have an 
> example of as to make this code? 
> 
> Até breve, 
> 
> Sérgio Gelli - Brasil


Sérgio,

In relation to Al's suggestion,
there is a demo for Win32Lib that I wrote 6 years ago, called "WalkDir",
which "lists all directories and files in a directory" or drive.
I just tested it on XP system & it seems to work ok.  Maybe it might be of
some use to you.

You could find it in the Win32Lib demo folder, or you could find "RunDemos" 
in that demo folder (I think "RunDemos" is a UTILITY, not a "demo", & should
be OUTSIDE the demo folder where it can be seen & more easily used), 
& then use the "RunDemos" utility to find "WalkDir" by tabbing to
"More Examples", where you'll see "WalkDir" in that list.

I tested it on an XP system, with "C:" & "subdirs?" checked, & it
appeared to make a full list of all files on the drive, with path info,
in alphabetic order (except it took upper case as "sooner" alphbetically 
than lower case).  It puts all the results into a listbox, but you should 
be able to easily put that a file instead.

It uses RECURSION, twice, and it also look "too clean" to be my code,
so it's possible Derek cleaned up my original submission.  

It's small enough that I'll copy it below for you.

Dan Moyer
(code follows:)
--  WalkDir: list all directories and files in a directory

--  Dan Moyer  September 10, 2000

--  Uses "walk_dir" *twice*; first to put into a list just the *files* 
--  (not the directories)in the target directory; then used again to
--  recursivly put all the directories and all their files in the same list


--    "walk_dir" has two parts: the "walk_dir" function which 
--	walks through a directory (or all subs, depending on last parameter:
--	0 is just the named directory, 1 is recurse through all sub d's);
--    and an associated USER CREATED FUNCTION which handles the results
--	of the walk through. walk_dir links to the user supplied function
--    with a statement like this:
--    exit_code = walk_dir(TargetDirectory, routine_id("UsersFunction"), 0)
--    of course, the user supplied function must reside ABOVE the walk_dir
--    that calls it.  And you can use more than one walk_dir, to call more
--    than one routine to do different things.

--  REQUIRES "file.e" to be included (is already included in Win32Lib)

--  RETURNS AS ELEMENTS OF ItemEntry: 
--  		 D_NAME, D_ATTRIBUTES, D_SIZE, D_YEAR, D_MONTH,	D_DAY,
--		 D_HOUR, D_MINUTE, D_SECOND

--  eg, ItemEntry[D_NAME] contains a filename,
--  and an attribute "d" signifies a directory


without warning
include win32lib.ew
if setAppName("WalkDir") then abort(0) end if

----------------------------------------------------------------
--  DEFINE WHAT DIRECTORY TO LOOK AT:
object TargetDirectory    
TargetDirectory = getenv("EUDIR") -- gets pathname for Euphoria directory

------------------------------------------------------------------
-- CREATE THE WINDOW:
constant 
TheWindow   = create( Window, "Find all directories and files in Euphoria
directory", 0, 100, 20, 640, 480, 0 )

-- CREATE A BUTTON:
constant ListAll = create( DefPushButton, "List All", TheWindow, 10, 10, 120,
30, 0 ),
DoSub   = create( CheckBox, "Subdirs?", TheWindow, 135, 10, 120, 30,
         0),
DirName = create( EditText, TargetDirectory, TheWindow, 260, 10, 370,
         30, 0)


-- CREATE A LISTBOX TO PUT DIRECTORY INFO INTO:
constant List1 = create( List, "", TheWindow, 40, 50, 550, 340, 0 )


integer Stopped
Stopped = 0
-----------------------------------------------------------------------
-- SET THE FONT STYLES IN THE BUTTON & LIST:
setFont( ListAll, "Times New Roman", 12, Bold )
setFont( List1, "Arial", 10, Normal )
--------------------------------------------------------------------------
--  ROUTINES:
-------------------------------------------------------------------------

-- NEXT, SHOWS ALL DIRECTORIES UNDER TOP DIRECTORY, AND ALL FILES IN THEM:
function ShowFilesAndDirs(sequence path_name, sequence ItemEntry)
sequence DirMarker

    -- Let Windows get a chance.
    doEvents(0)

-- SET A MARKER TO SHOW IN LIST IF FOUND A DIRECTORY:
  if equal(ItemEntry[D_ATTRIBUTES], "d") then
     DirMarker = "\\"
  else
     DirMarker = ""
  end if

--  PUT EACH ITEM INTO A LISTBOX:
   addItem( List1, path_name & "\\" & ItemEntry[D_NAME] & DirMarker )
   return Stopped  -- keep going (return a non-zero to stop it)
end function
------------------------------------------------------------------------
------------------------------------------------------------------------
--  CALLS THE ABOVE TWO FUNCTIONS, TO SHOW ALL FILES IN TARGET DIRECTORY
--  AND ALL DIRECTORIES UNDER IT & THEIR FILES:
with trace  
procedure onClick_ListAll(integer self, integer event, sequence parms)
integer exit_code
sequence labeltext

    if equal(getText(ListAll), "Stop") then
        Stopped = 1
        return
    end if
    
    eraseItems(List1)
    Stopped = 0
    setText(ListAll, "Stop")
    TargetDirectory = getText(DirName)
-- shows all directories (& the files in them) under TargetDirectory
--  (enabled by the "1" at end, in combination with its linked function): 
    exit_code = walk_dir(TargetDirectory, routine_id("ShowFilesAndDirs"),
          isChecked(DoSub) )

    if exit_code != 2 then
        setText(ListAll, "List All")
    end if

end procedure
setHandler(ListAll, w32HClick, routine_id( "onClick_ListAll" ))

procedure Close_TheWindow(integer self, integer event, sequence parms)
    Stopped = 2
    doEvents(0)
end procedure
setHandler(TheWindow, w32HClose, routine_id( "Close_TheWindow" ))

--=============================================================
WinMain( TheWindow, Normal )


new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu