***************************************************** ** MMLEX -- LEX files by M.Markov ** Files : ESCPS, INTLEXS, NUMFMTLXS, BINLEX6S, MMLEXV04S, MMLEXV04 * NOTE: MMLEXV4 combines all these LEX files into a single file. * This file is to be merged with the DIRLEX file in the not too * distant future, whenever I get some free time, and with PILEXTLX. ***************************************************** * ESCPS * * Syntax: A$=ESCP$($ [,#]) where $ stands for a string * parameter and # is a repeat multiplier. * For use with HP-IL video interfaces. * ESCP$("BC") ==> "1B421B43" or move the cursor down one * space and to the right one space. The repeat multiplier * will allow you to repeat this move # times. * To really see this work, first do DISPLAY IS *, otherwise * the operating system will send out control characters to * the display, messing up any fancy graphics you may want to * carry out. * * BUG: While you can easily do A$=ESCP$($,Y), you may find that * A$=ESCP$(string1,Y)&ESCP$(string2,Z) returns DATA TYPE ERR. This * seems to be linked with using the "&" concatenator AND the * optional parameter at the same time. While this is annoying, you * can work around this limitation with the ";" concatenator in * PRINT or DISP statments. Can anybody suggest a fix? * * coded by M. Markov, Ver. 2 ***************************************************** * INTLEXS * * The INT$ keyword suggested itself after I disassembled STD$ in the * DATA ACQUISITION ROM. What it does is return the same string you * would get by doing STD @ A$=STR$(INT(X)) -- which I do all too * often. This allows you to keep your favorite display format... * all you have to do is A$=INT$(X). * Coded by M. Markov in early March '87 ******************************************************************** * NUMFMTLXS ***************************************************** * * Syntax: A$=ENG$(X [,Y]) where X is the number to be converted to * a string in ENG Y format, without disturbing the current format * setting. * A$=ENG$(X) uses the value last set with FIX Y, SCI Y or ENG Y * to specify the # of digits to be shown. * * Also, A$=SCI$(X[,Y]) and A$=FIX$(X[,Y]) * * This keyword can help speed-up numeric tabulations by avoiding the * use of DISP USING or PRINT USING. Instead, use TAB, or O$[N]=ENG$(X,Y).. * * The ENG$ keyword suggested itself after I wrote the INT$ keyword. * I usually prefer using the STD display format, but I also often * want to print or display data in ENG 5 format. So, rather than * toggle back and forth between modes, a new keyword! * * Why not DISP USING? ... Because USING is slow! * * It should be noted that if you do ENG 5 @ STD, the * default number of integers / flags remain unchanged at 5. * This means that you can either preset this value as shown above, * or override this information with the optional parameter.. * * Coded by M. Markov in April '87 * * While we are here, we might as well provide the equivalent functions * for PRINTing or DISPlaying numbers in the FIX ? or SCI ? mode formats. * This can be done with almost no additional code, since the only change * required is one nib in the LCHEX instruction. We could also provide STD * formating, but that keyword is already provided by the DATALEX... * (See ULIB1 file for STD$ disassembly) * ******************************************************************** ***************************** * BINLEX6S - bit & byte twiddlers by M.Markov * The purpose of ATBIN$ is to convert a string into its * binary equivalent. For example: * * ATBIN$("A")="01000010" * * There are no restriction on the length of the parameter * string, and the resulting string will always be 8 times * the length of the input parameter, with leading zeroes * added as required. This implementation facilitates further * manipulations with logical operators such as AND$, OR$, ect.. * (See STRBOOL LEX). * * BTA$ performs the inverse operation, transforming * the binary representation (I think of it as a bit map) * back to an ascii string, base 256. * * An important design consideration was ease of use. * Therefore, I wanted BTA$ to handle input parameters with * "missing" leading zeroes... This means that BTA$("11") * is equivalent to BTA$("00000011"), both of which equal * CHR$(3). * * It is important to note that BTA$ does NOT trim leading * CHR$(0) bytes from the output string. The assumption is * that if you have modelled a CPU register to show, for * example, "0000000000000011", you want to model a full * 16 bit register, whose equivalent is CHR$(0)&CHR$(3). * * BTD is a conversion routine that returns the decimal * equivalent of a binary representation. Since the keyword * uses HDFLT, the maximum input parameter is RPT$("1",20), * which corresponds to a 20 bit address buss, with a maximum * address of FFFFF hex, or 1048575 decimal. This provides * a very comprehensive set of binary operators, when used * in conjunction with the HP-IL ROM binary functions BIT, * BINAND, BINCMP, BINEOR and BINIOR. * * DTBIN$ is the almost exact inverse of BTD. Syntax is: * C$=DTBIN$(X [,Y]) where X is the decimal value of the bit pattern * and Y is the length of the string to be created. This causes * and implicit MOD operation since only the Y least-significant bits * are actually converted. Like a register field wrap-around... * * NUMX is a variant of NUM($) that can return the full value of * a 2&1/2 nibble field in an ascii string. See inverse CHR2$(#) * below * SYNTAX: A=NUMX(A$) is equivalent to NUM(A$)*256+NUM(A$[2,2]) * There are some differences: if A$ is a one byte string, then * A=NUM(A$).. and if A$="" then A=0. I find this useful. * * NUMX also supports an optional numeric parameter: * A=NUMX(A$,N) where N>=3, and N<=LEN(A$) * A is a 2&1/2 byte conversion... for example, if * HEX$(A$)="01020304", then NUMX(A$,4)=HTD("20304")=131844 * NUMX(A$,3)=HTD("10203")=66051, and NUMX(A$,<<2 or less>>)=Invalid Arg. error * * The optional parameter allows you to decode/ unpack values up to * 1048575, acting as a true inverse of CHR2$. * * It is important to note that NUMX(A$[N]) may be equal to NUMX(A$,N+1) * but ONLY if HEX$(A$[N-1,N-1)])="?0". * An important applications for NUMX and CHR2$ is manipulating mass * storage pointers... * * NUMR(A$ [,Y]) works almost exactly like NUMX, the difference * being that it reverses the order of the data bytes in the field to be decoded. * This keyword was written originally to speed-up the * handling of HP-71 file length / record length * data in mass storage directory entries, where the least significant byte is stored * in the left-most part of the field - unlike * all other such data fields. This seems to be * an HP-71 implementation. Note that NUMR(A$)=NUM2(A$), where NUM2 is a * function from the Data Acquisition ROM. Thus, NUMR can * be considered an improved version. * * BUG: the method used to screen out invalid arguments for * BTA$ and BTD accept all characters such that MOD(NUM(chr),16)=0 or 1. * This could result in surprises, especially if you could run * into leading or trailing spaces.. To be fixed, maybe. * * Available memory test needs to be implemented for BTA$. * * CHR2$(X[,Y]) is a standard string function that, like * CHR$(X), returns (a) string character(s) of equivalent * value. The optional [,Y] parameter allows you to set * the length of the string that is returned. This allows * packing data in the range of 0-65535 into 2 byte string * elements, or data in the range of 0-1048575 into 3 byte * string elements. * -- the Y parameter defaults to 2 if not specified. * -- the Y parameter may vary from 0 to 1048575, and the * length of the string will be MOD(Y,16). * -- CHR2$ fills leading bytes with CHR$(0), as required. * This means that only the last five nibbles can actually * contain non-zero information. * * The default CHR2$(X) can replace X DIV 256,MOD(X,256) * in mass storage utilities that seek to position the read * head of a mass storage device to an absolute address X, * see for example SEND ... DDL 4 DATA CHR2$(2) * * Specifying a string length of 4 can be very handy when you * are building a new directory entry, or changing the offset * of an existing entry with programs like BCOPY... * * (Yes, more new damned keywords & changes to existing mass * storage utilities. some of them are real close to final, * ROMable form). *************************************************************