Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Invalid expression on 'erase' command

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Invalid expression on 'erase' command
#12542
Posted by: akochis 2008-12-02 23:16:14 Last edited by: Jeff Glatt 2009-03-04 13:53:19 (Total edited 1 time)
I installed Reglite. I found a sample script from Howard Fosdick on TechRepublic to identify large files on the system.  When I try to run it, I receive the error:

SYNTAX raised: Invalid expression.
Line 14 contains the statement: 'erase' sort_file output_file

I have attached the script I am trying to run. Do I have to configure Reginald to run an operating system command somehow?
reclaim gigabaytes.rex
andy kochis
Message2.
#12544
Posted by: Jeff Glatt 2008-12-03 01:45:03
To run command line programs under reginald lite, you need to download/install the RxCmd add-on library, and use its Command() function. See the help page "The REXX Language -> Running executables -> Run shell commands".

But don't do that if you just need to delete some files. Use Reginald's built-in function DeleteFile(). It's faster, more flexible, and provides better error feedback. See the help page "Files/Directories/Devices -> Delete files".
Message3.
#12547
Posted by: Doug Arndt 2008-12-03 23:24:29 Last edited by: Jeff Glatt 2009-01-01 06:58:43 (Total edited 3 times)
Andy, in your case you can replace the 'erase' line with:
rc = DELETEFILE(sort_file)
rc = DELETEFILE(output_file)
ps,  when in RPC, double click the function name to highlight it, then press F1
this takes you straight to the help page for the function.  Great way to learn more about REXX.


However .....

You're going to run into the same problem with the 'sort' and 'wordpad' lines.
And since that sort is using the DOS program, I've rewritten your script to save the directory entries into a rexx stem variable, then used the Reginald sort command to sort the data, then, wrote the output to your "sorted" file.
(I left the 'wordpad' command commented out)
/***************************************************************/ 
/* FIND BIG FILES */ 
/* */ 
/* Displays all files on an Windows XP machine, from largest */ 
/* to smallest, for easy identification of big obsolete files. */ 
/* */ 
/* Recursively traverses the directory tree. */ 
/* */ 
/***************************************************************/ 
start_dir = 'C:\'
sort_file. = ''                 /* file name array */
sort_sub = 0
output_file = 'c:\andy\zz_sortout.txt'   /* SORTed DIR listing is here */ 
rc = DELETEFILE(output_file)    /* Ensure files used are new */ 
list_files(1, start_dir)    /* Process the topmost directory */ 

SORT down sort_file. a .        /* sort decending on word 1 */
DO i = 1 TO sort_file.0         /* save sorted array */
  PARSE VAR sort_file.i size fn
  LINEOUT(output_file, FORMAT(size,15) fn)  
END
LINEOUT(output_file)       /* close output file */

/*
'wordpad' output_file           /* Let user view the big files */ 
*/

RETURN 0 
/* End the program */ 


 
list_files: PROCEDURE EXPOSE sort_file. sort_sub
iteration = ARG(1) /* Pick up the 2 input arguments,*/ 
search_dir = ARG(2) /* these are the Iteration # and */ 
/* the Directory to search */ 
more_to_process = 'YES' 
/* Set the processing flag on */ 
/* Do while there are more files & directories to process */ 
DO WHILE more_to_process = 'YES' 
/* MATCHNAME returns the next file or sub-directory name */ 
result = MATCHNAME(iteration, 'feedback', search_dir, 'DSNHCRAT', 'NS')
IF result \= "" /* Stop if MATCHNAME says to */ 
  THEN more_to_process = 'NO' 
  ELSE DO /* MATCHNAME returned an entry */ 
    /* This case is a File name, write it to the output list */ 
    IF feedback.0 \= "" THEN DO 
      sort_sub = sort_sub + 1
      sort_file.sort_sub = RIGHT(feedback.0,15,0) search_dir || feedback
    END 
  /* This case is a new sub-Directory to process. Process */ 
  /* the sub-Directory by calling LIST_FILES routine */ 
  ELSE DO 
    new_search_path = search_dir || feedback || '\' 
    result = list_files((iteration + 1), new_search_path) 
  END 
END 
END 
RETURN result
Doug
Message4.
#12548
Posted by: Doug Arndt 2008-12-03 23:50:37
Now, to finish this and activate wordpad ....

wordpad is a normal windows program, therefore the correct way to run it is from the Reginald  "iterateexe" function.

Remove the comments from the wordpad line, and change it to read:

rc = iterateexe('wordpad.exe', output_file)
Doug
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0