WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Revision to Shammas Book, Pages 182-183

Keywords: 	  Namir Shammas book errors

Question:

I am using a dirtree.wbt script file found in the "windows batch file programming" book i just recieved with my new copy of WinBatch 99. the script is attached below. I keep getting an error when i debug, or try to compile, on the line %lcldirlist%="\ ".

The script source appears on page 182-183.

Why isn't this working? Thank you in advance.

lclcurdir=dirget()

if param0>= 2
   lcldrive = param1
   lcldirlist = param2
else
   lcldrive = strsub(lclcurdir, 1, 2)
   cldirlist="dirlist"
endif

dirchange("%lcldrive%\")
%lcldirlist% = "\ "
lcli=1

while lcli <= itemcount(%lcldirlist%, @tab)
   lclrootdir = itemextract(lcli, %lcldirlist%, " ")
   dirchange(lclrootdir
   lclsdirlist=diritemize("*.*")
   lcln=itemcount(lclsdirlist, @tab)

   if lcln !=0
      for lclj = 1 to lcln
         lcldir = itemextract(lclj, lclsdirlist, @tab)
         %lcldirlist% = strcat(%lcldirlist%, lclrootdir, lcldir, "\")
      next
   endif

lcli=lcli+1
endwhile

drop(lcli, lclj, lcln, lcldirlist, lcldir, lclcurdir)
drop(.c.rootdir, lclsdirlist, lcldrive)
return

Answer:

Lines that were changed are UPPERCASED. Lines that were added are INDENTED.

Note that this routine only goes 2 levels deep, (in other words, it's not fully recursive)

;TREE.WBT
;corrected by Doug Staubach 3/13/99



  

lclcurdir   = dirget()

   INTCONTROL(29, @TAB, 0, 0, 0)

   INTCONTROL(5, 1, 0, 0, 0)

if param0  >= 2

lcldrive    = param1

LCLSTARTDIR = PARAM2

else

lcldrive    = strsub(lclcurdir, 1, 2)

LCLSTARTDIR = STRSUB(LCLCURDIR, 3, -1)

endif

   SLASHTEST=STRSUB(LCLSTARTDIR,STRLEN(LCLSTARTDIR),1)

   IF STRCMP(SLASHTEST,"\")!=0 THEN LCLSTARTDIR=STRCAT(LCLSTARTDIR,"\")

DIRCHANGE(LCLCURDIR)

   Z_TEMPFILE = FILEOPEN("TREE.DAT", "WRITE")

   Z_LINE = STRCAT(LCLDRIVE, LCLSTARTDIR, " ")

   FILEWRITE(Z_TEMPFILE, Z_LINE)

LCLDIRLIST = DIRITEMIZE("*.*")

lcli = 1

while lcli <= itemcount(lcldirlist, @tab)

LCLROOTDIR = ITEMEXTRACT(LCLI, LCLDIRLIST, @TAB)

   Z_LINE = STRCAT(LCLDRIVE, LCLSTARTDIR, LCLROOTDIR, "\ ")

   FILEWRITE(Z_TEMPFILE, Z_LINE)

DIRCHANGE(STRCAT(LCLDRIVE, LCLSTARTDIR, LCLROOTDIR))

lclsdirlist = diritemize("*.*")

lcln = itemcount(lclsdirlist, @tab)

if lcln != 0

for lclj = 1 to lcln

lcldir = itemextract(lclj, lclsdirlist, @tab)

   Z_LINE = STRCAT(LCLDRIVE, LCLSTARTDIR, LCLROOTDIR, "\", LCLDIR, "\ ")

   FILEWRITE(Z_TEMPFILE, Z_LINE)

next

endif

lcli = lcli+1

endwhile

   FILECLOSE(Z_TEMPFILE)

   DIRCHANGE(LCLCURDIR)

   RUN("NOTEPAD.EXE", "TREE.DAT")

drop(lcli, lcln, lclj, lcldirlist, lcldir, lclcurdir)

drop(lclrootdir, lclsdirlist, lcldrive)

drop(Z_TEMPFILE, Z_LINE, SLASHTEST, LCLSTARTDIR)

return

Article ID:   W14256
Filename:   Revision to Shammas Book Page 182.txt
File Created: 1999:10:26:11:22:50
Last Updated: 1999:10:26:11:22:50