LIBRARY :
STRING.ZIP( 14.2 KB)
; /// MACRO AND PROCEDURE DEFINITIONS USED IN THE STRING.RTF FILE ////
; ///////////////////////////////////////////////////////////////////////////////////////////////////////
.DATA
STRING STRUCT
STRINGBUFFER DB 255 DUP(0DH)
STRING ENDS
PARAMSBUFFER DB 255 DUP (0DH)
STRBUFFER DB 255 DUP (0DH)
NAMEOFMONTHS DB "JANUARY",0DH ; do not modify
DB "FEBRUARY",0DH
DB "MARCH",0DH
DB "APRIL",0DH
DB "MAY",0DH
DB "JUNE",0DH
DB "JULY",0DH
DB "AUGUST",0DH
DB "SEPTEMBER",0DH
DB "OCTOBER",0DH
DB "NOVEMBER",0DH
DB "DECEMBER",0DH
NAMEOFDAYS DB "TUESDAY",0DH ; do not modify
DB "WEDNESDAY",0DH
DB "THURSDAY",0DH
DB "FRIDAY",0DH
DB "SATURDAY",0DH
DB "SUNDAY",0DH
DB "MONDAY",0DH
DAYSOFMONTH DB 31,28,31,30,31,30,31,31,30,31,30,31,0DH
MPLMULSTR1 STRING <"0">
MPLMULSTR2 STRING <"0">
MPLMULSTR3 STRING <>
MPLMULSTR4 STRING <>
MPL32BITSTR1 STRING <"4294967296">
MPL32BITSTR2 STRING <>
Symbols String <"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ">
.CODE
TIMETOINT PROC
; clears a string
CLSSTR PROC
; strlen1- computes the length of the string which ds:si points at.
;
; inputs:
;
; ds:si- points at string to compute the length of.
;
; output:
; string ascii
; cx- length of string.
; preserves all other registers
; si = offset text
STRLEN PROC
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( string )
;strlower - changes bytes of a string to lower case
;
; inputs: ds:[si] = address of an ascii string
; 0dh end of string
; output: nothing
;* * * * * * * * * * * * * *
STRLOWER PROC
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( string )
;strupper - changes string to upper case
;; 0dh end of string
; inputs: ds:[si] pointing to string
;
; output: nothing
;* * * * * * * * * * * * * *
STRUPPER PROC
; inputs: ax = keycode returned by key_read or ah=0, al=ascii
;
; output: al = upper case ascii
UPCASECHAR PROC
UPCASECHAR ENDP
;
; inputs: ax = keycode returned by key_read or ah=0, al=ascii
;
; output: al = upper case ascii
LOWERCASECHAR PROC
; si = offset buffer
; al = char to count
COUNTCHAR PROC
TRIMLEFT PROC
TRIMRIGHT PROC
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( string )
;searches for a specified character in a string
;if char in string dx=1 else dx=0 bx=position of character
; case sensitive
; si = offset text
CHARPOS PROC
; si = offset text
SEARCHSTR2 PROC
STRPOS PROC
;replaces characters in a string with a character n times
; si = offset str1
; al = char
; cx = count
REPLACECHAREX PROC
;replaces a character in a string with another character
; si = offset str1
; al = char to replace
REPLACECHAR PROC
; deletes all occurances of a character from a string
; si = offset string
DELETECHAR PROC
DELETECHAR ENDP
; gets nth word in a string cares only space and tab
; esi = offset string
; edi = offset substring buffer
; dx = index
; dx = 1 if found bx = pos
GETWORD PROC
; gets nth string in a string cares ",",";"," (" and other word separation chars
; esi = offset string
; edi = offset substring
; dx = index
;output : dx = 1 if found bx = pos
GETWORDEX PROC
DELETEWORD PROC
DELETEWORDEX PROC
; searches for a whole word in a string
; cares tab and space as word separation chars
; case insensitive
; esi = offset string
; edi = offset word to search
; use comparestrcase to make this
SEARCHWORD PROC
; searches for a whole word in a string
; cares all word separation chars
; case insensitive
; esi = offset string
; edi = offset word to search
; use comparestrcase to make this
SEARCHWORDEX PROC
; searches for a whole word in a string
; cares tab and space as word separation chars
; case sensitive
; esi = offset string
; edi = offset word to search
; use comparestrnocase to make this
SEARCHWORDCASE PROC
; searches for a whole word in a string
; cares all word separation chars
; case sensitive
; esi = offset string
; edi = offset word to search
; use comparestrnocase to make this
SEARCHWORDEXCASE PROC
;--------------------------------------------------------------------------------
; deletes the first substring in a string not cares whole words
; output : es:[di] contains substring
; to see output use
; strbuffer = new string
; strbuffer should be moved to message1 and
; message1 should have enough space to contain the new string
; si = offset message1
; di = offset message2
STRDEL PROC
;--------------------------------------------------------------------------------
;deletes all occurances of a substring in a string
; not cares whole substring
;output : es:[di] contains substring
;to see output use
; strbuffer = new string
; strbuffer should be moved to message1 and
; message1 should have enough space to contain the new string
; case sensitive
; si = offset message1
STRDELEX PROC
; reverses a string
STRREVERSE PROC
; reverses words of a string
; cares all word separation characters
STRREVERSEEX PROC
;--------------------------------------------------------------------------------
;copies substring in a string from the specified position
;output : es:[buffer] contains substring
;to see output use
;showmessage 10,10,buffer,15
; si = offset str
; di = offset strbuffer
; bx = pos
STRCOPY PROC
; replaces a substring in a string
; string in es:si
; sub string in ds:di
; modifies si and di
; si points to ending position of substring
; di points to ending position of string
; di = offset str
; si = offset substr
; bx = pos
; str should have enough space for replacement
STRREPLACE PROC
; deletes cx chars from a string from the specified position
; si = offset str
; bx = pos
STRCUT PROC
STRCUT ENDP
; trims a string from the specified position
; esi = offset str
STRTRIM PROC
; inserts a substring into a string from the specified position
; string should have enough space to hold the new string
; si = offset string
; di = offset substring
STRINSERT PROC
; concat : concatenates two strings
; string and sub string should be declared as string type
; or string should have enough space to hold the substring
; for example if length of string is 20 and length of substring
; is 5 there should be 5 more bytes space to get the substring
; si = offset string
CONCAT PROC
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( compare )
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( compare )
; strlcomp - compares ascii strings,case sensitive
;
; output: if match dx=1
; if different dx=0
; * * * * * * * * * * * * * *
; si = offset text1
STRLCOMP PROC
; //////////////////// ( compare ) ////////////////////////////
; strcomp - compares ascii strings,case insensitive
;
; output: if match dx=1
; if different dx=0
; ////////////////////////////////////////////////////////////////////////////
; si = offset text1
STRCOMP PROC
STRCOMP ENDP
; ////////////
COMPARESTRNOCASE2 PROC
; compareword - compares ascii strings,case sensitive
;
; output: if match dx=1
; if different dx=0
; * * * * * * * * * * * * * *
; si = offset text1
COMPAREWORDCASE PROC
; //////////////////// ( compare ) ////////////////////////////
; compareword - compares ascii words ina string
;case insensitive
; output: if match dx=1
; if different dx=0
; ////////////////////////////////////////////////////////////////////////////
; si = offset text1
COMPAREWORD PROC
COMPAREWORD ENDP
; comparewordcaseex - compares ascii strings,case sensitive, update registers
; output: if match dx=1
; if different dx=0
; * * * * * * * * * * * * * *
; si = offset text1
COMPAREWORDCASEEX PROC
; //////////////////// ( compare ) ////////////////////////////
; comparewordex - compares ascii words ina string
;case insensitive
; output: if match dx=1
; if different dx=0
; ////////////////////////////////////////////////////////////////////////////
; si = offset text1
COMPAREWORDEX PROC
; edi = pos
PARAMS PROC
; si = offset paramsbuffer
; di = offset buffer
GETPARAM PROC
; di = offset buffer
; si = offset paramsbuffer
; bx = paramno
;
GETFILEPARAM PROC
; si should be loaded before calling this macro
; numbers all zero based
; si = offset text
; bl = char
; dx = n times
FINDNTHCHAR PROC
ISNUM PROC
; num should be uppercased if char
ISNUMBER PROC
ISDECIMAL PROC
ISCHAR PROC
ISALPHA PROC
CHARTONUM PROC
NUMTOCHAR PROC
; strnum should be uppercased
; esi = offset strnum
; ecx = base
STRTOINT PROC
; eax = number
; ecx = base
; esi = offset stringbuffer
INTTOSTR PROC
; converts an integer string to a string
STRTOSTRF PROC
; converts an integer to a string
INTTOSTRF PROC
STRFTOSTR PROC
; esi = offset string1
; edi = offset string2
; output dx = 0 if equal
; dx = 1 if first string bigger
STRINTCOMP PROC
; adds two string and stores result in strbuffer
; esi = offset string1
; edi = offset string2
STRADD PROC
; subtracts two string and stores result in strbuffer with sign
; esi = offset string1
; edi = offset string2
STRSUB PROC
; esi = string1
; ebx = base
; ecx = number to multiply
STRMULEX PROC
; esi = string1
; ebx = base
; ecx = number to multiply
STRMUL PROC
; esi = string1
; ecx = number to div
; ebx = base
; output= strbuffer holds the result string
; edx = remainder
; below base ten and base 16 support only
; due to the inefficiencies of strtoint's isnum proc
; isnum can determine only other bases
; isnum,isnumber and strtoint should be replaced with
STRDIV PROC
; edx:eax = int64
; ebx = base
INT64TOSTR PROC
; gets current date,month and day from a given string
; string should be in dd/mm/yyyy format
; output
; dx = year
; bx = month
; ax = day
DECODEDATETIME PROC
; gets current date,month and day
; output
; dx = year
; bx = month
GETDATE PROC
; before this procedure
; getdate or sortdate should be called
; or ax,bx,dx should be
; loaded with appropriate values
; dx = year
; bx = month
; ax = day
DATETOSTR PROC
; converts current date to a string, months are names
; before this procedure
; getdate or sortdate should be called
; or ax,bx,dx should be
; loaded with appropriate values
; dx = year
; bx = month
; ax = day
DATETOSTRLONG PROC
; calculates total days since 01/01/1980
; cares leap years
; before this procedure
; getdate or decodedatetime should be called
; or ax,bx,dx should be
; loaded with appropriate values
; dx = year
; bx = month
; ax = day
DATETOINT PROC
; get name of current day into a string
; before this procedure
; getdate or decodedatetime should be called
; or ax,bx,dx should be
; loaded with appropriate values
; dx = year
; bx = month
; ax = day
DAYOFWEEK PROC
; gets current hour,minute and second
; output
; dx = second
; bx = minute
GETTIME PROC
; before this procedure
; gettime or decodedatetime should be called
; or ax,bx,dx should be
; loaded with appropriate values
; dx = second
; bx = minute
; ax = hour
TIMETOSTR PROC
; calculates seconds since midnight
; before this procedure
; gettime or decodedatetime should be called
; or ax,bx,dx should be
; loaded with appropriate values
; dx = second
; bx = minute
; ax = hour
TIMETOINT PROC
; si = offset fromstr
MOVESTR PROC
; si = offset fromstr
; di = offset tostr
MOVEWORD PROC
CLEARDATA PROC
; esi = offset fromstr
STRTODATA PROC
; fs:esi = offset data
; edi = offset str
DATATOSTR PROC
; entry
; fs:si = start of mem1
; ds:bx = offset string to find
; output
; dx = 1 if found else dx = 0
FINDTEXT PROC
;------------------------------------------------------------------------------
; si = offset str
; di = offset substr
; cx = pos
XINSERTSUBINSTR PROC
; esi = offset string
; al = char
; edx = position
INSERTCHARNTIMES PROC
INSERTCHARNTIMES2 MACRO STR,CHAR,POS,COUNT