1. Please help with Formatting Programme Output
- Posted by Les Rogers <selgor1 at verizonmail.com> Jan 29, 2007
- 604 views
This programme prints all directories and all files in directory and all sub-directories and files :- include file.e include get.e constant TRUE=1 object exit_code atom k,w k=0 function look_at(sequence path_name,sequence entry) if k=0 then printf(1,"%s\n\n",{path_name}) k=1 end if puts(1,"\t") printf(1,"%s",{entry[D_NAME]}) puts(1,"\n") return 0 end function exit_code=walk_dir("c:\\", routine_id("look_at"),TRUE) k=0 w=wait_key() Format I would like is :- Directory name files ........... indented as shown Sub-Directory ........ indented as shown files ........... indented as shown Next Directory Name files Sub-Directory files etc. I don't know how to tell the computer when a new directory is there and how to distinguish a file from a directory ?????? if it is too difficult then O.K. Thank you for taking time to read my message . les.r.
2. Re: Please help with Formatting Programme Output
- Posted by Chris Bensler <bensler at nt.net> Jan 29, 2007
- 579 views
Les Rogers wrote: > > > This programme prints all directories and all files > in directory and all sub-directories and files :- > > include file.e > include get.e > constant TRUE=1 > object exit_code > atom k,w > k=0 > > function look_at(sequence path_name,sequence entry) > if k=0 then printf(1,"%s\n\n",{path_name}) k=1 end if > puts(1,"\t") > printf(1,"%s",{entry[D_NAME]}) > puts(1,"\n") > return 0 > end function > > exit_code=walk_dir("c:\\", routine_id("look_at"),TRUE) > k=0 > w=wait_key() > > Format I would like is :- > > Directory name > files ........... indented as shown > > Sub-Directory ........ indented as shown > files ........... indented as shown > > Next Directory Name > files > > Sub-Directory > files > > etc. > > I don't know how to tell the computer when a new directory is there > and how to distinguish a file from a directory ?????? > > if it is too difficult then O.K. > > Thank you for taking time to read my message . > > les.r. integer tabs tabs = 0 function look_at(sequence path_name,sequence entry) if k=0 then printf(1,"%s\n\n",{path_name}) k=1 end if printf(1,"%s%s\n",{repeat('\t',tabs),entry[D_NAME]}) if find('d',entry[D_ATTRIBUTES]) then tabs += 1 end if return 0 end function hope that helps Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria
3. Re: Please help with Formatting Programme Output
- Posted by Chris Bensler <bensler at nt.net> Jan 29, 2007
- 579 views
Chris Bensler wrote: I made a mistake. repeat() will not accept a zero count (as would be in the first call to look_at()) Easy fix: function repeat0(object x, integer count) if count then return repeat(x,count) else return "" end if end function integer tabs tabs = 0 function look_at(sequence path_name,sequence entry) if k=0 then printf(1,"%s\n\n",{path_name}) k=1 end if printf(1,"%s%s\n",{repeat0('\t',tabs),entry[D_NAME]}) if find('d',entry[D_ATTRIBUTES]) then tabs += 1 end if return 0 end function Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria
4. Re: Please help with Formatting Programme Output
- Posted by Robert Craig <rds at RapidEuphoria.com> Jan 29, 2007
- 574 views
- Last edited Jan 30, 2007
Chris Bensler wrote: > Chris Bensler wrote: > I made a mistake. > repeat() will not accept a zero count (as would be in the first call to > look_at()) You didn't make a mistake. repeat(x, 0) works as you would expect. It returns the empty (length-0) sequence: {} (equivalent to "") > Easy fix: > function repeat0(object x, integer count) > if count then > return repeat(x,count) > else > return "" > end if > end function Not necessary! Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
5. Re: Please help with Formatting Programme Output
- Posted by Chris Bensler <bensler at nt.net> Jan 29, 2007
- 564 views
- Last edited Jan 30, 2007
Robert Craig wrote: > > Chris Bensler wrote: > > Chris Bensler wrote: > > I made a mistake. > > repeat() will not accept a zero count (as would be in the first call to > > look_at()) > > You didn't make a mistake. > repeat(x, 0) works as you would expect. > It returns the empty (length-0) sequence: {} (equivalent to "") Interesting. I don't know why I thought that. Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria