GRADE ***** Grade.Txt Last updated by Roedy Green on 98/05/22 Classifies files as small or large and sets the ERRORLEVEL. WARNING GRADE WORKS ONLY ON 8.3 FILENAMES. Abstract ******** GRADE classifies files as small or large and sets the errorlevel accordingly. You might say it separates the sheep from the goats. It is typically used to trigger re-building the Magellan primary index when the secondary index get too big. GRADE includes the 856 byte COM file, MASM/OptAsm source code, and documentation. Written by Roedy Green of Canadian Mind Products. Copyrighted but may be copied freely for Non-military use only. Usage ***** GRADE C:\MySub\MyFile.Ext 9999999 to see if file is smaller than 9999999 bytes long error ERRORLEVEL=2 larger ERRORLEVEL=1 equal ERRORLEVEL=1 smaller ERRORLEVEL=0 Examples of Use *************** Grade C:\MySub\MyFile.Ext 1024 REM Must test big errorlevels first IF ERRORLEVEL 2 GOTO Error IF ERRORLEVEL 1 GOTO BigOrEqual IF ERRORLEVEL 0 GOTO Small The program will display one of two messages: File: C:\Mysub\MyFile.Ext is small or File: C:\Mysub\MyFile.Ext is large These messages could be redirected for later processing with: GRADE C:\MySub\MyFile.Ext 1024 >> MyList.Bat GETTING THE LATEST VERSION ************************** Look for the latest version at my Web site: http://mindprod.com Notes ***** GRADE is like a egg sorting machine that grades files into two classes depending on whether the file is smaller than the given limit or not. GRADE sets the ERRORLEVEL to 0 for files smaller than the limit, 1 for equal, 1 for larger and 2 for no such file. It displays a messages telling whether the file is small or large. Files equal to the limit are also considered big. Using pipes you can redirect this message to file for further processing. GRADE does not change the size of the file or create files. If you need to create an empty file, try EMPTY.COM. If you need to create one of a certain size, try RESIZE.COM. Uses for GRADE ************** 1. Checking when it is time to re-index Magellan. When the secondary index gets too large, you can rebuild the primary index. REM Re-index Magellan when index gets up to 300,000 bytes. CD \MAG2 GRADE ALLDRIVE.IX5 300000 IF ERRORLEVEL 1 MG /keys={AltF5}R{Enter}{Enter}{F10}Y 2. Warning when files are getting too big for efficiency and need to be split. GRADE C:\MySub\MyCode.ASM 10000 IF ERRORLEVEL 1 Echo Consider splitting MyCode.ASM into modules. 3. Preparing lists of small or large files that can then be massaged with the FIND command or a text processor to create bat files to operate only on the small or large files. GRADE C:\MySub\MyFile.Ext 1024 >> MyList.Bat GRADE C:\MySub\MyOther.Ext 1024 >> MyList.Bat . . . Find "is small" MyList.Bat > MySmall.Bat Find "is large" MyList.Bat > MyLarge.Bat Commonly asked Questions and Answers ************************************ > What if I wanted to classify files into more categories than > just small and big? This version of GRADE uses only two categories, small and large. The code has been written is such a way it could be easily changed to generate small, equal and big. I felt that for normal use, the clumsiness of handling many different ERRORLEVELs outweighed the advantages of greater control. Without even changing GRADE, you could get the effect you wanted this way: GRADE C:\MySub\MyFile.Ext 1024 If ERRORLEVEL 1 Goto Large GRADE C:\MySub\MyFile.Ext 1023 If ERRORLEVEL 1 Goto Equal GoTo Small --- > I typed GRADE C:\MySub\*.BAT 1024 >> Mylist.Bat > I expected a list of all the files categorized. Mylist.Bat was > effectively empty. What's wrong with GRADE? GRADE is indeed brain damaged. It does not understand wildcards. Part of the reason I did not take the extra effort to implement wildcards, was I did not know what I to do with the multiple ERRORLEVELS. The other reason was laziness. I needed GRADE simply to trigger my Magellan re-indexes. I had no need for wildcards. --- > GRADE is a pretentious name for this trivial utility. It > categorizes only by size. Grading implies categorizing by > quality, date, attribute bits etc. This runt of a utility > doesn't do any such thing! You are completely correct. I hope in future that other people will take this source code and add the features to make GRADE live up to its name. >I wrote my Bat file, but it treats ALL files as small no matter >how big they are. In DOS, IF ERRORLEVEL 0 means If ERRORLEVEL is greater or equal to zero. You were assuming it meant if ERRORLEVEL equals 0. In practice, do your errorlevel checks biggest first. e.g. IF ERRORLEVEL 2 GOTO Error IF ERRORLEVEL 1 GOTO BigOrEqual IF ERRORLEVEL 0 GOTO Small not IF ERRORLEVEL 0 GOTO Small IF ERRORLEVEL 1 GOTO BigOrEqual IF ERRORLEVEL 2 GOTO Error Author ****** Please report bugs and problems to: Roedy Green Canadian Mind Products #101 - 2536 Wark Street Victoria, BC Canada V8T 4G8 tel:(250) 361-9093 mailto:roedyg@mindprod.com http://mindprod.com You are free to copy and cannibalize the source code in any way you want with the one exception that you may not use any of it for a military purpose. The one exception is U.N. sanctioned peacekeeping missions. It would also be helpful if you mentioned the URL or source of where you got your copy. I want to make sure that site is kept kept up to date. -30-