(User.programs) Item: 367 by akcs.softcalc@hpcvbbs.cv.hp.com Author: [brian maguire] Subj: Miscellaneous utilities Date: Sun Mar 22 1992 MISC1 : Miscellaneous Utilities 1 Copyright 1991 Brian J. Maguire All Rights Reserved MISC1 and this manual are presented without warranties, expressed or implied. The author makes no guarantee as to the fitness of this software. MISC1 can be copied freely provided the software and this manual are copied in its entirety. The user cannot be charged, in whole or in part, except for the cost of reproduction. No part of this package may be used for commercial purposes without written permission from the author. Please forward comments or questions to... Brian Maguire 139 Kingsbury Dearborn, MI 48128 (313) 274-0428 SUMMARY For quite some time I have been designing several tool libraries. While reviewing them, several commands were eliminated because they were impractical. Rather than just throwing them in the fire, I decided to release them in the public domain. A brief listing of the programs in UTIL1 is given below. Each name is followed by a brief description and the INPUT->OUTPUT object types. CSTK Checks a list of object type numbers with the stack. Each number in the list on level one specifies a stack level. If fewer objects are on the stack than specified by the list, -1 is returned. If the objects on the stack match the list, 1 is returned. Otherwise 0 is returned. As an example, if the stack is setup as shown below and CSTK is run, 1 is returned. NOTE: Using 27 in the object type list passes all object type in that stack position. [If you're like me and can't remember all the object type numbers, use TSTK, described below, to find them. -jkh-] Before After ------ ----- 4: 'VAR' 4: 'VAR' 3: 45 3: 45 2: "Answer " 2: "Answer " 1: { 6 0 2 } 1: 1 List -> Real(-1, 0, or 1) TSTK Returns a list of object type numbers representing the objects on the stack. The real number input on level one specifies the number of stack levels to check. As an example, entering TSTK with the before stack shown below will return the after stack. Before After ------ ----- 5: 'PRG1' 5: 'PRG1' 4: << 2 / >> 4: << 2 / >> 3: 2 3: 2 2: "Name " 2: "Name " 1: 4 1: { 6 8 0 2 } Obj(n)...Obj(1), Real(n) -> Obj(n)...Obj(1), List TCOUNT Returns the number of occurrences of an object type found in the list on level two. The real number on level one specifies the object type. TCOUNT can be used to validate user input lists. For example, the program << IF DUP SIZE OVER 6 TCOUNT == THEN ELSE END >> check for a list of global names on the stack. If the test is true the appropriate procedure is run. Otherwise, is run. List, Real -> Real TPOS Returns the position of the first occurrence of an object type in a list. The real number on level one specifies the object type to be searched for. 0 is returned if the object type is not found List, Real -> Real OCOUNT Returns the number of times the object on level one occurs in the list on level two. List, Any -> Real STOPATH STOPATH stores an object in a different directory without changing directories. If the global name on level one exists anywhere along the current path, its contents is replaced with the object on level two. Otherwise, a new variable is created in the current directory. Any, Global -> Object on level two stored in global name ->STR1 Converts the object on level one into a string without carriage returns. Spaces are the only separator character used. Any -> String -Brian Maguire-