Professional Documents
Culture Documents
7-0
16-Jan-1998
Introduction
1. MONITORING TIME
2. RECEIVED/SENT BY
3. MONITORED MESSAGE
4. MESSAGE DATA (can also be empty)
Definition of a datablock
The datablock is one or multiple lines of text that have following properties:
1. all characters are hexadecimal 0-9, A-F, a-f
2. only allowed delimiters are spaces,tabs, comma, and dash (-)
3. all hexadecimal strings must have length 2, 4 or 8 digits
4. each dataline begins with the dataprefix string, if such is defined
5. the block ends with a empty line, or line not matching rules 1 to 4
The return string either represents all data as bytes (mode 0), or structured
mode, which maintains the sizeinfo (mode 1). Additionally the style can be
modified by specifiying which delimiter is used between data items. Following
delimeters can be used:
• space
• comma
• dash (-)
• none (compressed style)
• any string (wild style)
Function groups
Nr Function group
1 Debug functions
2 File functions
3 Hexadecimal string functions
4 Bytestring functions
5 Bitfield functions
6 Binary file function
7 String functions
8 Token functions
9 Delimiter modifications
10 Packed digit conversions
11 BigEndian conversions
12 Translation table functions
13 Field lookup table functions
Debug functions (1)
type function returns
STR VersionString() version info
STR ErrorString() error msg
DW ErrorCode() error code
DW Debug(DW mode,DW delay) -
STR PrototypeByIndex(DW index) prototype string
STR PrototypeByName(STR name) prototype string
STR ObsoleteFunction(DW index) prototype string
VersionString
Returns the version string of the library. This information is important when
trying to solve problems that are due to use of incompatible or obsolete library
versions.
ErrorCode
Returns errorcode of last library function. Code zero means no error. See the
list of errorcodes in the appendix A
ErrorString
Returns a string containing extra information of the last error, in addition to the
errorcode.
Debug
Turn debugging on. This function creates an modeless dialog that displays
extra debugging info. The output to the window can be delayed, so that
information in the debug window scrolls slower. Return value: zero.
PrototypeByIndex
Returns the function prototype, when index is given. Returns empty string if
function does not exist.
PrototypeByName
Returns the function prototype, when function name is given. Returns empty
string if function does not exist.
ObsoleteFunction
Returns the prototype of an obsolete library function.
File functions (2)
type function returns move fpos
DW UseFileHandle(W hfile) // HIT 1.6 linenumber yes
DW UseFile(STR filename) // HIT 2.x linenumber yes
STR DataPrefix(STR data_prefix) old prefix -
DW FindString(STR substring) linenumber* yes
DW FindHex() linenumber* yes
DW FindMsg(W msg) linenumber* yes
STR ReadLine() line of text yes
STR ReadHexLines(DW mode,STR delimiter,DW n_lines) data string yes
STR ReadHexBlocks(DW mode,STR delimiter,DW n_blocks) data string yes
STR ReadMsg(DW mode,STR delimiter) data string yes
STR MsgTime() timestamp -
STR MsgSndRcv() SR-info -
STR MsgHdr(DW mode,STR delimiter) datastring -
DW SkipLines(DW n_lines) skipped count yes
DW SkipHexLines(DW n_hexlines) skipped count yes
DW SkipHexBlocks(DW n_hexblocks) skipped count yes
DW SkipMsg(DW n_msg) skipped count yes
DW CountGroups() count -
DW CountLines() count -
DW CountMsg(W msg,DW start_line,DW end_line)+ count -
DW GotoLine(DW line_nr) linenumber yes
DW FileSeek(DW file_position) linenumber yes
DW FileTell() abs.filepos -
DW StartOfGroup(DW group) linenumber -
DW EndOfGroup(DW group) linenumber -
DW CurLine() linenumber -
UseFile (2.x)
Same functionality as for the UseFileHandle, except that file is closed when
libary is released with the dllfree() -call or an empty filename is given. This
function must be used when macro is executed on HIT 2.x
DataPrefix
Defines a string that must be found at beginning of a line of hexdata. Only lines
with this prefix are examined for data. Returns previous prefix string. The
Prefix string is set to default (empty) when the UseFileHandle() function is
called.
FindMsg
Returns the line number where a message was found. The function searches for
a given message. Message 0xFFFF is a wildcard, that matches to any message.
Function returns zero, if no message was found.
NOTE: current fileposition updated only if a message is found
FindBlk
Returns the line number where a hexadecimal datablock was found. Function
returns zero if no data was found.
NOTE: current fileposition updated only if data is found
FindStr
Returns the line number of a line that contains the substring. Function returns
zero if no line matched the search criteria.
NOTE: current fileposition is updated only if a matching line is found
ReadLine
Function reads the current line. The current fileposition is advanced by one
line. Returns EOF=chr(26) if end of file was reached.
ReadHexLines
Function reads one line of data, starting at the current fileposition. Current
fileposition is advanced by one line. If current line contains any data, the data is
packed into the return string. Returns empty string if no data available
ReadBlocks
Function reads a given amount of blocks, starting at the current fileposition.
Current fileposition is advanced accordingly.
ReadMsg
Function reads one message, starting at the current fileposition.
The function returns the message header and the data. Returns empty string if
current line is not at the beginning of a message.
MsgTime
Returns the message header part containing the timestamp
MsgSndRcv
Returns sender/receiver info.
MsgHdr
Returns the 16 byte messageheader.
MsgData
Returns the message data.
SkipLines
Skips given amount of lines, current fileposition is advanced accordingly.
Returns number of skipped lines
SkipBlocks
Skips given amount of data blocks, current fileposition is advanced
accordingly. Returns number of skipped blocks
SkipMsg
Skips given amount of messages, current fileposition is advanced accordingly.
Returns number of skipped messages
CurLine
Returns current line (current fileposition).
GotoLine
Go to specified line (change current fileposition). Returns the current
fileosition
FileSeek
Go to specified absolute fileposition.The final fileposition is adjusted to the
beginning of the line. Function returns current line
FileTell
Returns absolute fileposition or (-1) if failure.
GotoLine
Go to specified line (change current fileposition). Returns the current
fileosition
StartOfGroup
Returns linenumber where group starts
EndOfGroup
Returns linenumber where group ends
Count Lines
Returns number of lines in the workfile.
CountMsg
Returns number of occurrences of a certain message (or all,0xFFFF).
The search is made within the given range of lines.
Hexadecimal string functions (3)
type function returns
DW CountHex(STR s) number of ..
STR GetHex(STR s,DW item_index) hexstr
DW SetHex(STR s,DW item_index,DW value) success *
STR ShiftHexLeft(STR s) hexstr
*) 0=failure, 1=sucess
CountHex
Returns number of hexadecimal items in a the string.
SetHex
Inserts an hexadecimal number into give position of the string.
Returns FALSE if unsuccessful.
GetHex
Returns hexadecimal number from string at given position.
ShiftHexLeft
Returns first hexadecimal number in a string. Argument string is shifted to the
left.
Bytestring functions (4)
type function returns
DW CountBytes(STR bytestr) number of ..
STR GetBytes(STR source,DW startbyte,DW n_bytes) bytestring
DW SetBytes(STR dest,DW startbyte,DW n_bytes,STR success *
source)
*) 0=failure, 1=success
CountBytes
Returns number of bytes in the bytestring.
GetBytes
Returns part of the source bytestring, starting at given byte, continuing wanted
number of bytes. Similar to ReadBin() function, but applied to a string instead
of a file.
SetBytes
Replaces part of the destination bytestring with bytes from the sourcestring.
Startbyte and number of bytes is given. Returns FALSE if unsuccessful
Bitfield functions (5)
type function returns
STR GetField(STR s,DW startbyte,W startbit, W n_bit) 32-bit value
DW SetField(STR s,DW startbyte,W startbit, W n_bit,DW x) sucess *
GetField
Returns a 32-bit value, from the source bytestring. The field position is
indicated using a position triplet (start byte,start bit,number of bits).
SetField
Replaces a bitfield value within the source bytestring. The field position is
indicated using a position triplet (start byte,start bit,number of bits).
Returns FALSE if unsuccessful.
The startbit and number of bits are used to describe the location of the bitfield
withn the 32-bit DWORD value.
Binary file functions (6)
type function returns
DW FileSize() size
STR ReadBin(STR filename,DW from,DW n_bytes) bytestring
DW CountTickets(STR filename) number of ..
STR Read Ticket(STR filename,DW ticket_number) bytestring
GetFileSize
Function returns size of a binary or textfile. Size is given in bytes.
ReadBin
Returns a byte-string from the target file, starting from the startbyte, and
continuing with wanted amount of bytes.
CountTickets
Returns number of charging tickets found in a DX charging record. These files
are often called ticket files or simply “DAT”-files
ReadTicket
Returns one ticket from the ticket file. Tickets numbering starts with zero.
String functions (7)
type function returns
STR StringFrom(STR s,DW index) substring
STR TrimEnd(STR s) substring
STR SkipSpaces(STR s) substring
DW WildCompare(STR s,STR wildcard) 0, 1
StringFrom
Returns remaining part of string, starting at given position.
TrimEnd
Removes trailing whitespaces from string. Source string is truncated
SkipSpaces
Returns string without leading whitespaces
WildCompare
Returns TRUE (=1) if string matches the wildcard, otherwise FALSE (=0).
The wildcard allows 2 degrees of freedom (**). Examples:
Example Comment
abcdef 1. exact
abc* 2. prefix match
*def 3. end of string match
*cd* 4. substring
a*cd*f 5. prefix+substring+eofs
ab*ef 6. prefix+eofs
* 7. any match
ABC* 8. not found
NOTE: the wildcard string should not have more than 2 wildcards.
The result of the comparision will be undefined if 3 or more (***..)
wildcards are used.
Token functions (8)
type function example
DW CountTokens(STR s,STR special_chr) “a b c,d” -> 4
STR GetToken(STR s,STR special_chr,DW ix) “a b c,d”,2 -> “c”
STR ShiftTokenLeft(STR s,STR special_chr) “a b c,d” -> “a” + “b c,d”
CountTokens
Returns number of tokens. Each token are separated by spaces,tabs and comma.
The special character string allows other characters to act as separateors
between tokens. Spaces and commas are does not count as own tokens, unless
listed in the special character string.
GetToken
Returns one token form the token string. Index starts from zero.
ShiftTokenLeft
Returns first token in string. The target string is shifted left by removing the
first token from the original string. When last token is shifted out, the source
string becomes empty.
Delimiter modifications (9)
type function example
STR ChangeDelimiter(STR s,STR new_delimiter) 12/34/56 -> 12,34,56
STR UnCompress(STR source, STR delimiter) 00112233 -> 00,11,22
Change Delimiter
Returns string where all hexadecimal items are separated by the same delimiter.
UnCompress
Returns string with delimiters inserted between every byte.
Packed digit conversions (10)
type function example
STR PackedDigits(STR digits,W filldigit) 12345,F -> 21_43_F5
STR UnpackedDigits(STR digits) 21_43_F5 -> 12345F
PackedDigits
Returns bytestring. The leftmost digit in the source string is the least significant
nybble (4-bit) in the result string. If the source has an odd number of digits, the
filler digit is used. This conversion is often used in TUP signalling
UnpackedDigits
Returns string. This function is the reverse of PackedDigits()
BigEndian conversion (11)
type function example
STR HexStrToBytes(STR source,DW n_bytes) 123,4 ->23_01_00_00
STR BytesToHexStr(STR source) 23_01_00_00 -> 123
STR XtoBytes(DW value,DW n_bytes) 0x123,4 ->23_01_00_00
DW BytesToX(STR source) 23_01_00_00 -> 0x123
HexStrToBytes
Returns bytestring. The least significant digit in the source string is the least
significant nybble (4-bit) in the result string. Result string is padded with
zeroes until desired length is obtained (n_bytes=0, no padding)
BytesToHexStr
Returns hexadecimal string. The least significant nybble (4-bit) in the source
string is the least significant digit in the result string.
XtoBytes
Returns bytestring. Result string is padded with zeroes until desired length is
obtained (n_bytes=0, no padding)
BytesToX
Returns hexadecimal value. Max. 8 bytes (32 bit)
Translation table functions (12)
type function example
STR TranslateXtoS(STR fname,DW x) 0x6034 -> “c_test_msg_s”
DW TranslateStoX(STR fname,STR s) “c_test_msg_s” -> 0x6034
STR TranslateItoS(STR fname,STR s) “AIF” -> “Air Interface”
STR TranslateStoI(STR fname,STR s) “Air Inter” -> AIF
TranslateXtoS
Returns a string from the translation table that matches the integer X. The
translation table is a file containing hexadecimal numbers and associated
strings. The hexadecimal with leading zeores, or prexfix ‘0x’ are equally
accepted.
TranslateStoX
Returns an integer from the translation table that matches the string S. The
translation table is a file containing hexadecimal numbers and associated
strings. Match is based on substring occurrence
TranslateItoS
Returns an description string from the translation table that matches the
identifier I. The translation table is a file containing identifier strings and
associated description strings. Match is based on exact string occurrence
TranslateStoI
Returns an identifier string from the translation table that matches the
desctription string S. The translation table is a file containing identifier strings
and associated description strings. Match is based on substring occurrence
FindStruct
Returns string containing the structure (either message or file definition) that
matches both the environment and the structure name. Returns empty string if
no matching line was found from the field lookup file.
GetEnvName
Returns string containing the environment string for last matching structure
found with the FindStruct() function.
CountFields
Returns number of fields found for last matching structure found with the
FindStruct() function.
FieldByIndex
Returns string containing the position triplet and fieldname. Must be preceeded
by a call to the FindStruct() function.
FieldByName
Returns string containing the position triplet and fieldname. Must be preceeded
by a call to the FindStruct() function. The fieldname match is made using the
same wildcards as the WildCompare() function
CountConstants
Returns number of constants associated with the current field. Must be
preceeded by a call to either the FieldByIndex() or the FieldByName() function.
ConstantByIndex
Returns constant string associated with the current field. Function be preceeded
by call to either the FieldByIndex() or the FieldByName() function.
ConstantByName
Returns constant string associated with the current field.
ConstantByValue
Returns constant string associated with the current field.
The string buffer functions allow the user to pass pointers to DLL-functions
where the reference target is a binary object instead of a zero-terminated string.
Funtion Description
BufferReadFile Read file contents into string, inserting data at
given buffer index, and reading the given amount
of bytes from the beginning of the file.
BufferWriteFile Write buffer contents into file, starting at given
buffer index, and writing given amount of bytes.
Limitations
#ifdef __WIN32__
#define DLLFUNC WINAPI
#else
#define DLLFUNC FAR PASCAL
#endif
#define MAX_STRING_SIZE 32000 /* return value string, max 32.000 bytes */
#define MAX_LINE_LEN 1000 /* max line length for fileread */
enum ErrCodes
{
ERR_NONE=0, /* no error, OK */
ERR_NO_FILEHANDLE, /* no file handle associated */
ERR_EOF, /* EOF found before searched item */
ERR_SETHEX_OVERFLOW, /* SetHex overflow */
ERR_SETBITS_OVERFLOW, /* SetBits overflow */
ERR_BITFIELD, /* Get/SetBits bitfield error */
ERR_INTERNAL, /* internal error */
ERR_INDEX_TOO_LARGE, /* index beyond table end */
ERR_LINENUM_TOO_LARGE, /* too large linenumber */
ERR_BYTEPOS_TOO_LARGE, /* bytepos too large */
ERR_STARTBYTE_TOO_LARGE, /* Get/Setbytes, startbyte too large */
ERR_FILE_NOT_FOUND, /* file not found */
ERR_NOTRANSLATION, /* translation failed */
ERR_STRUCT_NOT_FOUND, /* FindStruct failed */
ERR_FIELD_NOT_FOUND, /* FieldByName/FieldByIndex failed */
ERR_CONST_NOT_FOUND, /* ConstantByName/ByIndex/ByValue failed */
ERR_FILESEEK, /* FileSeek error */
ERR_FILETELL, /* FileTell error */
ERR_GOTO_EOF, /* GotoLine beyond EOF */
};
extern "C"
{
// Debug functions (1)
STRING DLLFUNC ErrorString(void);
DWORD DLLFUNC ErrorCode(void);
DWORD DLLFUNC Debug(DWORD level,DWORD delay_ms);
STRING DLLFUNC PrototypeByIndex(DWORD ix);
STRING DLLFUNC PrototypeByName(STRING function_name);
STRING DLLFUNC ObsoleteFunction(DWORD ix);
// File functions (2)
STRING DLLFUNC DataPrefix(STRING dta_prefix);
DWORD DLLFUNC UseFileHandle(WORD Hfile);
DWORD DLLFUNC GotoLine(DWORD line_nr);
DWORD DLLFUNC CountLines(void);
DWORD DLLFUNC CountGroups(void);
DWORD DLLFUNC CountMsg(WORD msg,DWORD start_line,DWORD end_line);
DWORD DLLFUNC SkipLines(DWORD n_lines);
DWORD DLLFUNC SkipHexLines(DWORD n_blk);
DWORD DLLFUNC SkipHexBlocks(DWORD n_blk);
DWORD DLLFUNC SkipMsg(DWORD n_msg);
STRING DLLFUNC ReadLine(void);
STRING DLLFUNC ReadHexLines(DWORD mode,STRING delim,DWORD n_lines);
STRING DLLFUNC ReadHexBlocks(DWORD mode,STRING delim,DWORD n_blk);
STRING DLLFUNC ReadMsg(DWORD mode,STRING delim);
STRING DLLFUNC MsgTime(void);
STRING DLLFUNC MsgSndRcv(void);
STRING DLLFUNC MsgHdr(DWORD mode,STRING delim);
STRING DLLFUNC MsgData(STRING delim);
DWORD DLLFUNC FindStr(STRING substr);
DWORD DLLFUNC FindHex(void);
DWORD DLLFUNC FindMsg(WORD msg);
STRING DLLFUNC VersionString(void);
DWORD DLLFUNC CurLine(void);
DWORD DLLFUNC StartOfGroup(DWORD group_ix);
DWORD DLLFUNC EndOfGroup(DWORD group_ix);
DWORD DLLFUNC FileSeek(DWORD fpos);
DWORD DLLFUNC FileTell(void);
// Hexadecimal string functions (3)
DWORD DLLFUNC CountHex(STRING s);
STRING DLLFUNC GetHex(STRING s,DWORD ix);
DWORD DLLFUNC SetHex(STRING s,DWORD ix,DWORD value);
STRING DLLFUNC ShiftHexLeft(VARSTR s);
// Bytestring functions (4)
DWORD DLLFUNC CountBytes(STRING s);
STRING DLLFUNC GetBytes(STRING s,DWORD startbyte,DWORD nbytes);
DWORD DLLFUNC SetBytes(STRING s,DWORD startbyte,DWORD nbytes,STRING s2);
// Bitfield functions (5)
DWORD DLLFUNC GetBits(DWORD bytepos,WORD bitpos,WORD n_bits,STRING s);
DWORD DLLFUNC SetBits(DWORD bytepos,WORD bitpos,WORD n_bits,STRING s,DWORD value);
// Binary file functions (6)
DWORD DLLFUNC FileSize(STRING filename);
STRING DLLFUNC ReadBin(STRING filename,DWORD start,DWORD nbytes);
STRING DLLFUNC ReadTicket(STRING filename,DWORD ticket_no);
DWORD DLLFUNC CountTickets(STRING filename);
// String functions (7)
STRING DLLFUNC StringFrom(STRING s,DWORD index);
STRING DLLFUNC TrimEnd(VARSTR s);
STRING DLLFUNC SkipSpaces(STRING s);
DWORD DLLFUNC WildCompare(STRING s,STRING wildcard);
// Token functions (8)
STRING DLLFUNC ShiftTokenLeft(VARSTR s,STRING extra_delimiters);
STRING DLLFUNC GetToken(STRING s,STRING extra_delimiters,DWORD index);
DWORD DLLFUNC CountTokens(STRING s,STRING extra_delimiters);
// Delimiter modifications (9)
STRING DLLFUNC ChangeDelimiter(STRING s,STRING new_delimiter);
STRING DLLFUNC Uncompress(STRING s,STRING new_delimiter);
// Packed digit conversion (10)
STRING DLLFUNC PackedDigits(STRING s,WORD filldigit);
STRING DLLFUNC UnpackedDigits(STRING s);
// BigEndian conversions (11)
STRING DLLFUNC HexStrToBytes(STRING s,WORD nbytes);
STRING DLLFUNC BytesToHexStr(STRING s);
STRING DLLFUNC XtoBytes(DWORD value,WORD n_bytes);
DWORD DLLFUNC BytesToX(STRING s);
// Translation table functions (12)
STRING DLLFUNC TranslateXtoS(STRING fname,DWORD x);
DWORD DLLFUNC TranslateStoX(STRING fname,STRING s);
STRING DLLFUNC TranslateItoS(STRING fname,STRING id);
STRING DLLFUNC TranslateStoI(STRING fname,STRING s);
// Fieldtable lookup functions (13)
STRING DLLFUNC FindStruct(STRING filename,STRING envname,STRING structname);
STRING DLLFUNC GetEnvName();
DWORD DLLFUNC CountFields(void);
STRING DLLFUNC FieldByIndex(DWORD index);
STRING DLLFUNC FieldByName(STRING name);
DWORD DLLFUNC CountConstants(void);
STRING DLLFUNC ConstantByIndex(DWORD ix);
STRING DLLFUNC ConstantByName(STRING s);
STRING DLLFUNC ConstantByValue(DWORD x);
// string buffer functions (14)
DWORD DLLFUNC _export BufferSetByte(STRING s,WORD ix,DWORD value);
DWORD DLLFUNC _export BufferSetWord(STRING s,WORD ix,DWORD value);
DWORD DLLFUNC _export BufferSetDword(STRING s,WORD ix,DWORD value);
DWORD DLLFUNC _export BufferGetByte(STRING s,WORD ix);
DWORD DLLFUNC _export BufferGetWord(STRING s,WORD ix);
DWORD DLLFUNC _export BufferGetDword(STRING s,WORD ix);
DWORD DLLFUNC _export BufferReadFile(STRING s,WORD ix,WORD nbytes,STRING fname);
DWORD DLLFUNC _export BufferWriteFile(STRING s,WORD ix,WORD nbytes,STRING fname);
DWORD DLLFUNC _export BufferMemMove(STRING dest,WORD xd,STRING src,WORD xs,WORD
nbytes);
DWORD DLLFUNC _export BufferMemSet(STRING s,WORD ix,DWORD value,WORD nbytes);
//
DWORD DLLFUNC UseFile(STRING fname);
}
Error Codes
Code Remark
00 ERR_NONE no error occurrred
01 ERR_NO_FILEHANDLE no file handle associated
02 ERR_EOF EOF found before searched item
03 ERR_SETHEX_OVERFLOW SetHex overflow
04 ERR_SETBITS_OVERFLOW SetBits overflow
05 ERR_BITFIELD Get/SetBits bitfield error
06 ERR_INTERNAL internal error
07 ERR_INDEX_TOO_LARGE index beyond table end
08 ERR_LINENUM_TOO_LARGE too large linenumber
09 ERR_BYTEPOS_TOO_LARGE bytepos too large
10 ERR_STARTBYTE_TOO_LARGE Get/Setbytes, startbyte too large
11 ERR_FILE_NOT_FOUND file not found
12 ERR_NOTRANSLATION translation failed
13 ERR_STRUCT_NOT_FOUND FindStruct failed
14 ERR_FIELD_NOT_FOUND FieldByName/FieldByIndex failed
15 ERR_CONST_NOT_FOUND ConstantByName/ByIndex/ByValue failed
16 ERR_FILESEEK FileSeek
17 ERR_FILETELL FileTell
18 ERR_GOTO_EOF GotoLine beyond EOF
Version history
File Vers. Date Comment
hexdata.cpp 1.1-0 15-feb-96 HEXDATA source code
1.2-0 24-apr-96 second beta test version
1.3-0 11-may-96 third beta test version
1.4-0 31-july-96 64k bug fixed
1.5-0 08-Sep-96 32-bit update for HIT 2.0-b2
1.6-0 16-Sep-97 fix 4kb read problem, TOFE 381603
1.7-0 16-Jan-98 New: String Buffer functions (14)
Examples
File Vers. Date Comment
hexdata.lst 1.2-0 11-may-96 list of all macros
testall.hit 1.2-0 11-may-96 test all prototypes
hexdatXX.hit 1.3-0 19-oct-96 example macros, XX=01,02,..,19
lines.txt 1.2-0 11-may-96 example data, message monitoring
translat.txt 1.2-0 11-may-96 example data, translation table
fields.txt 1.2-0 11-may-96 example data, field lookup
mpty6210.dat 1.2-0 11-may-96 example data, charging file
$
$ use/database=SATK HEXDATA
%USE-I-NEWSUBSYS, Default subsystem changed to HEXDATA
$ list/vers HEXDATA.*
HEXDATA.CPP 1.7-0
HEXDATA.DLL 1.7-0
HEXDATA.DOC 1.7-0
HEXDATA.H 1.7-0
HEXDATA.LST 1.2-0
HEXDATA.RC 1.7-0
$
Design recommendations for DLL-libarys
VERSION INFORMATION
a) the DLL should have function that return version information.
Example:
the version info from the SPM system could be used as default
1) "ICON" or
2) "ICON_1"
PROTOTYPE INFORMATION
WRAPPING HIT-MACROS
NOTE: these rules does not apply on the beta version HEXDATA 1.3-0
HEXDATA.LST
!
! @(#)MID: HEXDATA.LST 1.2-0 96/05/11
!
E HEXDAT01.HIT // Read Lines from file (2)
E HEXDAT02.HIT // Read Block from file (2)
E HEXDAT03.HIT // Read Message from file (2)
E HEXDAT04.HIT // Count occurrences (2)
E HEXDAT05.HIT // Find occurrences (2)
E HEXDAT06.HIT // Skip lines & messages (2)
E HEXDAT07.HIT // FileSeek & FileTell (2)
E HEXDAT08.HIT // Hexadecimal string functions (3)
E HEXDAT09.HIT // Bytestring functions (4)
E HEXDAT10.HIT // Bitfield functions (5)
E HEXDAT11.HIT // Binary file functions (6)
E HEXDAT12.HIT // String functions (7)
E HEXDAT13.HIT // Token functions (8)
E HEXDAT14.HIT // Delimiter modifications (9)
E HEXDAT15.HIT // Packed digits conversions (10)
E HEXDAT16.HIT // BigEndian conversions (11)
E HEXDAT17.HIT // Translation table functions (12)
E HEXDAT18.HIT // Field lookup table functions (13)
E HEXDAT19.HIT // Prototype functions (1)
E TESTALL.HIT // Check all DLL prototypes
Example Macros
//
// HEXDAT01.HIT - Read Lines from file (2)
//
// @(#)MID: HEXDAT01.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",fname="lines.txt";
const string Pas="Pascal";
integer hxd;
function main()
integer hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
hfile=fileopen(fname,READ);
if(hfile>=0)
test_dllfuncs(hfile);
fileclose(hfile);
else
printlog("file '%s' - open failed\n",fname);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function main()
integer hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()","Pascal"));
hfile=fileopen(fname,READ);
if(hfile>=0)
test_dllfuncs(hfile);
fileclose(hfile);
else
printlog("file '%s' - open failed\n",fname);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
a:0026-4405-00DA-0000-00-01-0000-0994-0004
b:37 00 05 44 DA 00 00 00 00 11 00 00 95 09 00 00
function main()
integer hxd,hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
hfile=fileopen(fname,READ);
if(hfile>=0)
test_dllfuncs(hxd,hfile);
fileclose(hfile);
else
printlog("file '%s' - open failed\n",fname);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
lnr=28
a:1994-04-18 01:31:54.95
b:S 01B0 00DD 00
c:0014,C000,01E8,0001,00,11,0000,5017,0000
d:44 44 44 00
function main()
integer hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
hfile=fileopen(fname,READ);
if(hfile)
test_dllfuncs(hfile);
fileclose(hfile);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
CountLines=39
CountGroups=2
CountMsg(FFFF)=5
CountMsg(5017)=2
function main()
integer hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
hfile=fileopen(fname,READ);
if(hfile)
test_dllfuncs(hfile);
fileclose(hfile);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
FindStr=4
>line 4: for HEXDATA library
FindHex=13
>11 11 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 58 00 15 FF
FindMsg=15
>MONITORING TIME: 1994-04-18 01:31:34.47 // message #2
FindMsg=23
>MONITORING TIME: 1994-04-18 01:31:54.95 // message #3
function main()
integer hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
hfile=fileopen(fname,READ);
if(hfile)
test_dllfuncs(hfile);
fileclose(hfile);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
s=dllfunction(hxd,"Dw=FindHex()",Pas); n=strtoint(s,DEC);
printlog("FindHex=%d (linenumber)\n",n);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=GotoLine(Dw)",Pas,n);
s=dllfunction(hxd,"Dw=SkipHexLines(Dw)",Pas,2);
printlog("SkipHexLines=%s\n",s);
s=dllfunction(hxd,"Dw=CurLine()",Pas);
printlog("CurLine=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=GotoLine(Dw)",Pas,1);
s=dllfunction(hxd,"Dw=FindMsg(W)",Pas,msg);
printlog("FindMsg(%04X)=%s (linenumber)\n",msg,s);
s=dllfunction(hxd,"Dw=SkipHexBlocks(Dw)",Pas,2);
printlog("SkipHexBlocks=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=GotoLine(Dw)",Pas,1);
s=dllfunction(hxd,"Dw=SkipMsg(Dw)",Pas,3);
printlog("SkipMsg=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
pause(55);
endfunction
version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11
function main()
integer hfile;
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
hfile=fileopen(fname,READ);
if(hfile)
test_dllfuncs(hfile);
fileclose(hfile);
else
printlog("file '%s' - open failed\n",fname);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
dllfunction(hxd,"Dw=UseFileHandle(W)",Pas,hfile);
s=dllfunction(hxd,"Dw=FileSeek(Dw)",Pas,55); err();
printlog("FileSeek=%s (line number)\n",s); // always to beginning of line
s=dllfunction(hxd,"Dw=FileTell()",Pas); err();
printlog("FileTell=%s (byte)\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=FileTell()",Pas); err();
printlog("FileTell=%s (byte)\n",s);
s=dllfunction(hxd,"Dw=GotoLine(Dw)",Pas,1);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
pause(55);
endfunction
function err()
// printlog("ERR: '%s'\n",dllfunction(hxd,"S=ErrorString()",Pas));
endfunction
________________________
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string a,b;
integer i,n;
b=dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
b=dllfunction(hxd,"Dw=CountHex(S)",Pas,a);
printlog("CountHex=%s\n",b); n=strtoint(b,DEC);
for(i=0;i<n;i++)
b=dllfunction(hxd,"Dw=SetHex(S,Dw,Dw)",Pas,a,i,i+0x90);
b=dllfunction(hxd,"S=GetHex(S,Dw)",Pas,a,i);
printlog("GetHex(%d)=%-6s , a=%s\n",i,b,a);
endfor
printlog("a=%s\n",a);
b=dllfunction(hxd,"S=GetHex(S,Dw)",Pas,a,3);
printlog("GetHex=%s\n",b);
b=dllfunction(hxd,"Dw=SetHex(S,Dw,Dw)",Pas,a,3,0x999);
printlog("SetHex=%s\n",b);
b=dllfunction(hxd,"S=ErrorString()","Pascal");
printlog("Error: %s\n",b);
while(a<>"")
b=dllfunction(hxd,"S=ShiftHexLeft(S)",Pas,a);
printlog("ShiftHexLeft=%-6s, a='%s'\n",b,a);
endwhile
pause(55);
endfunction
________________________
CountHex=5
GetHex(0)=90 , a=90 11 22 33 - 0056
GetHex(1)=91 , a=90 91 22 33 - 0056
GetHex(2)=92 , a=90 91 92 33 - 0056
GetHex(3)=93 , a=90 91 92 93 - 0056
GetHex(4)=0094 , a=90 91 92 93 - 0094
a=90 91 92 93 - 0094
GetHex=93
SetHex=0
Error: SetHex, overflow
ShiftHexLeft=90 , a='91 92 99 - 0094'
ShiftHexLeft=91 , a='92 99 - 0094'
ShiftHexLeft=92 , a='99 - 0094'
ShiftHexLeft=99 , a='0094'
ShiftHexLeft=0094 , a=''
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,x="00 11 22 33 44 55 66 77 88 99 AA";
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"Dw=CountBytes(S)",Pas,x);
printlog("CountBytes=%s\n",s);
s=dllfunction(hxd,"S=GetBytes(S,Dw,Dw)",Pas,x,1,3);
printlog("GetBytes=%s\n",s);
s=dllfunction(hxd,"Dw=SetBytes(S,Dw,Dw,S)",Pas,x,1,3,"AA BB CC");
printlog("SetBytes=%s, x=%s\n",s,x);
pause(55);
endfunction
________________________
CountBytes=11
GetBytes=11 22 33
SetBytes=1, x=00 AA BB CC 44 55 66 77 88 99 AA
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,bs="00 11 22 33 44 55 66 77";
integer x;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"Dw=GetBits(Dw,W,W,S)",Pas,3,4,16,bs);
x=strtoint(s,DEC); printlog("GetBits=0x%X\n",x);
s=dllfunction(hxd,"Dw=SetBits(Dw,W,W,S,DW)",Pas,3,0,16,bs,0x9988);
printlog("SetBits=%s, bs=%s\n",s,bs);
pause(55);
endfunction
________________________
GetBits=0x5443
SetBits=1, bs=00 11 22 88 99 55 66 77
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,f="MPTY6210.DAT";
integer i,n;
s=dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,0);
s=dllfunction(hxd,"Dw=CountTickets(S)",Pas,f);
n=strtoint(s,DEC);
for(i=0;i<n;i++)
s=dllfunction(hxd,"S=ReadTicket(S,Dw)",Pas,f,i);
if(strlength(s)>80) s[60]=0; endif
printlog("%d: %s\n",i,s);
endfor
printlog("CountTickets=%d\n",n);
s=dllfunction(hxd,"Dw=FileSize(S)",Pas,f);
printlog("Filesize=%s (bytes)\n",s);
s=dllfunction(hxd,"S=ReadBin(S,Dw,Dw)",Pas,f,0,16);
printlog("ReadBin=%s\n",s); // first 16 bytes
pause(55);
endfunction
________________________
0: A1 00 00 FF 01 00 25 07 44 03 90 F0 FF FF FF FF FF FF 97 01
1: 7C 00 05 97 01 00 00 00 D9 3C 33 41 15 00 00 44 03 90 F0 FF
2: 7C 00 05 98 01 00 00 00 B6 3D 33 41 15 00 00 44 03 90 F0 FF
3: 7C 00 05 99 01 00 00 00 C7 3D 33 41 16 00 00 44 03 90 F0 FF
4: 7C 00 05 00 02 00 00 00 86 3E 33 41 16 00 00 44 03 90 F0 FF
5: 7C 00 05 01 02 00 00 00 EA 3D 33 41 16 00 00 44 03 90 F0 FF
6: 7C 00 05 02 02 00 00 00 0D 3E 32 41 21 00 00 44 03 90 F0 FF
7: 7C 00 05 03 02 00 00 00 C2 3E 32 41 21 00 00 44 03 90 F0 FF
8: 7C 00 05 04 02 00 00 00 2E 3E 32 41 21 00 00 44 03 90 F0 FF
9: 7C 00 05 05 02 00 00 00 45 3E 31 41 1B 00 00 44 03 90 F0 FF
10: 04 01 01 06 02 00 00 00 DB 62 31 41 1B 00 00 44 03 90 F0 FF
11: B7 00 02 07 02 00 00 00 FD 40 31 41 1B 00 00 44 03 90 F0 FF
12: 55 00 15 08 02 00 00 00 8D 39 31 41 1B 00 00 44 03 90 F0 FF
13: 18 00 10 44 03 90 F0 FF FF FF FF FF FF 03 51 11 01 04 94 19 08 02 00 00
14: A1 00 00 FF 01 00 94 06 44 03 90 F0 FF FF FF FF FF FF 09 02
15: 04 01 01 09 02 00 00 00 C3 62 32 41 21 00 00 44 03 90 F0 FF
16: B7 00 02 10 02 00 00 00 C1 40 32 41 21 00 00 44 03 90 F0 FF
17: 55 00 15 11 02 00 00 00 9A 39 32 41 21 00 00 44 03 90 F0 FF
18: 04 01 01 12 02 00 00 00 4D 64 33 41 16 00 00 44 03 90 F0 FF
19: B7 00 02 13 02 00 00 00 B6 41 33 41 16 00 00 44 03 90 F0 FF
20: 55 00 15 14 02 00 00 00 9C 39 33 41 16 00 00 44 03 90 F0 FF
21: 04 01 01 15 02 00 00 00 09 65 33 41 15 00 00 44 03 90 F0 FF
22: B7 00 02 16 02 00 00 00 5E 42 33 41 15 00 00 44 03 90 F0 FF
23: 18 00 10 44 03 90 F0 FF FF FF FF FF FF 00 52 11 01 04 94 19 16 02 00 00
CountTickets=24
Filesize=4088 (bytes)
ReadBin=A1 00 00 FF 01 00 25 07 44 03 90 F0 FF FF FF FF
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s="\t tabs and returns \r\n",
WC="Dw=WildCompare(S,S)";
integer i;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"S=TrimEnd(S)",Pas,s);
printlog("TrimEnd='%s'\n",s);
s=dllfunction(hxd,"S=SkipSpaces(S)",Pas,s);
printlog("SkipSpaces='%s'\n",s);
s=dllfunction(hxd,"S=StringFrom(S,Dw)",Pas,s,5);
printlog("StringFrom='%s'\n",s); delay(3000);
for(i=1;i<=N;i++)
printlog("i=%d, wc('%s')=%s\n",i,tbl[i],dllfunction(hxd,WC,Pas,tbl[1],tbl[i]));
endfor
pause(55);
endfunction
________________________
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,ts,special=",+-*/=";
integer i,n;
CountTokens=9
GetToken(0)='a'
GetToken(1)=','
GetToken(2)='b(c,d,"e f")'
GetToken(3)='+'
GetToken(4)='f'
GetToken(5)='+'
GetToken(6)='g"a b"'
GetToken(7)='("("tan(x))'
GetToken(8)='+'
---
a , ts=',b(c,d,"e f")+f+g"a b" ("("tan(x))+ '
, , ts='b(c,d,"e f")+f+g"a b" ("("tan(x))+ '
b(c,d,"e f") , ts='+f+g"a b" ("("tan(x))+ '
+ , ts='f+g"a b" ("("tan(x))+ '
f , ts='+g"a b" ("("tan(x))+ '
+ , ts='g"a b" ("("tan(x))+ '
g"a b" , ts='("("tan(x))+ '
("("tan(x)) , ts='+ '
+ , ts=''
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,x="00 - 11 + 22 / 33 , 44";
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"S=ChangeDelimiter(S,S)",Pas,x,",");
printlog("ChangeDelimiter=%s\n",s); // use "," instead
s=dllfunction(hxd,"S=Uncompress(S,S)",Pas,"123456",",");
printlog("Uncompress=%s\n",s); // 123456 => 12,34,56
pause(55);
endfunction
________________________
ChangeDelimiter=00,11,22,33,44
Uncompress=12,34,56
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"S=UnPackedDigits(S)",Pas,s);
printlog("UnPackedDigits=%s\n",s);
s=dllfunction(hxd,"S=UnPackedDigits(S)",Pas,s);
printlog("UnPackedDigits=%s\n",s);
pause(55);
endfunction
________________________
PackedDigits=214365F7
UnPackedDigits=1234567F
PackedDigits=2143
UnPackedDigits=1234
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
integer x=0x12345;
string s;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"S=HexStrToBytes(S,W)",Pas,"12345",4);
printlog("HexToBytes=%s\n",s);
s=dllfunction(hxd,"S=BytesToHexStr(S)",Pas,s);
printlog("BytesToHexStr=%s\n",s);
s=dllfunction(hxd,"S=XtoBytes(Dw,W)",Pas,x,4);
printlog("XtoBytes=%s\n",s);
s=dllfunction(hxd,"Dw=BytesToX(S)",Pas,s);
printlog("BytesToX=%08X\n",strtoint(s,DEC));
pause(55);
endfunction
________________________
HexToBytes=45 23 01 00
BytesToHexStr=0000012345
XtoBytes=45 23 01 00
BytesToX=00012345
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,f="TRANSLAT.TXT";
integer x;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"S=TranslateXtoS(S,Dw)",Pas,f,0x132);
printlog("XtoS=%s\n",s);
s=dllfunction(hxd,"S=TranslateXtoS(S,Dw)",Pas,f,0xA0);
printlog("XtoS=%s\n",s);
s=dllfunction(hxd,"S=TranslateXtoS(S,Dw)",Pas,f,0xC0);
printlog("XtoS=%s\n",s);
s=dllfunction(hxd,"Dw=TranslateStoX(S,S)",Pas,f,"AIF prog");
x=strtoint(s,DEC); printlog("StoX=%X\n",x);
s=dllfunction(hxd,"S=TranslateStoI(S,S)",Pas,f,"Home Loc");
printlog("StoI=%s\n",s);
s=dllfunction(hxd,"S=TranslateItoS(S,S)",Pas,f,"HLR");
printlog("ItoS=%s\n",s);
pause(55);
endfunction
________________________
function main()
hxd=dllload(libname);
if(hxd)
print("version: %s\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
print("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s,f="fields.txt";
integer lnr;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"S=FindStruct(S,S,S)",Pas,f,"7.6-1 *","6034 *");
printlog("FindStruct='%s'\n",s);
if(s<>"")
s=dllfunction(hxd,"Dw=CountFields()",Pas);
printlog("CountFields='%s'\n",s);
s=dllfunction(hxd,"S=FieldByIndex(Dw)",Pas,0);
printlog("FieldByIndex='%s'\n",s);
s=dllfunction(hxd,"S=FieldByName(S)",Pas,"test_id");
printlog("FieldByName='%s'\n",s);
s=dllfunction(hxd,"Dw=CountConstants()",Pas);
printlog("CountConstants=%s\n",s);
s=dllfunction(hxd,"S=ConstantByName(S)",Pas,"reset*");
printlog("ConstantByName=%s\n",s);
s=dllfunction(hxd,"S=ConstantByIndex(Dw)",Pas,1);
printlog("ConstantByIndex=%s\n",s);
s=dllfunction(hxd,"S=ConstantByValue(Dw)",Pas,2);
printlog("ConstantByValue=%s\n",s);
s=dllfunction(hxd,"S=GetEnvName()",Pas);
printlog("GetEnvName='%s'\n",s);
endif
s=dllfunction(hxd,"S=FindStruct(S,S,S)",Pas,f,"*","*another*");
printlog("FindStruct='%s'\n",s);
pause(55);
endfunction
// NOTE: FindStruct(), FindField(), ConstantByName()
// uses same wildcards as the WildCompare() function
________________________
FindStruct='6034 c_test_msg'
CountFields='3'
FieldByIndex='0 1 8 test_id'
FieldByName='0 1 8 test_id'
CountConstants=6
ConstantByName=0 reset_all_tests
ConstantByIndex=1 set_all_tests
ConstantByValue=2 test_write_log
GetEnvName='7.6-1 M7'
FindStruct='AAAA another_test_msg'
integer hxd;
function main()
hxd=dllload(libname);
if(hxd)
printlog("version: %s\n\n",dllfunction(hxd,"S=VersionString()",Pas));
test_dllfuncs();
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string a,b,c,f1="VersionString",f2="kukkuu";
integer i;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
for(i=0;i<999;i++)
a=dllfunction(hxd,"S=PrototypeByIndex(Dw)",Pas,i);
if(a=="") break; endif
printlog("%d: %s\n",i,a);
endfor
printlog("---\n%d functions\n",i);
a=dllfunction(hxd,"S=PrototypeByName(S)",Pas,f1);
b=dllfunction(hxd,"S=PrototypeByName(S)",Pas,f2);
c=dllfunction(hxd,"S=ObsoleteFunction(Dw)",Pas,0);
printlog("a='%s'\nb='%s'\nc='%s'\n",a,b,c);
pause(55);
endfunction
continued ...
version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11
0: S=ErrorString()
1: S=VersionString()
2: Dw=ErrorCode()
3: S=PrototypeByIndex(Dw)
4: S=PrototypeByName(S)
5: S=ObsoleteFunction(Dw)
6: Dw=Debug(Dw,Dw)
7: Dw=UseFileHandle(W)
8: S=DataPrefix(S)
9: Dw=GotoLine(Dw)
10: Dw=CountLines()
11: Dw=CountGroups()
12: Dw=CountMsg(W,Dw,Dw)
13: Dw=SkipLines(Dw)
14: DW=SkipHexLines(Dw)
15: Dw=SkipHexBlocks(Dw)
16: Dw=SkipMsg(Dw)
17: S=ReadLine()
18: S=ReadHexLines(Dw,S,Dw)
19: S=ReadHexBlocks(DW,S,Dw)
20: S=ReadMsg(Dw,S)
21: S=MsgTime()
22: S=MsgSndRcv()
23: S=MsgHdr(Dw,S)
24: S=MsgData(S)
25: Dw=FindStr(S)
26: Dw=FindHex()
27: Dw=FindMsg(W)
28: Dw=CurLine()
29: Dw=StartOfGroup(Dw)
30: Dw=EndOfGroup(Dw)
31: Dw=FileSeek(Dw)
32: Dw=FileTell()
33: Dw=CountHex(S)
34: Dw=SetHex(S,Dw,Dw)
35: S=GetHex(S,Dw)
36: S=ShiftHexLeft(S)
37: Dw=CountBytes(S)
38: S=GetBytes(S,Dw,Dw)
39: Dw=SetBytes(S,Dw,Dw,S)
40: Dw=GetBits(Dw,W,W,S)
41: Dw=SetBits(Dw,W,W,S,DW)
42: Dw=FileSize(S)
43: S=ReadBin(S,Dw,Dw)
44: Dw=CountTickets(S)
45: S=ReadTicket(S,Dw)
46: S=StringFrom(S,Dw)
47: S=TrimEnd(S)
48: S=SkipSpaces(S)
49: Dw=WildCompare(S,S)
50: Dw=CountTokens(S,S)
51: S=ShiftTokenLeft(S,S)
52: S=GetToken(S,S,Dw)
53: S=ChangeDelimiter(S,S)
54: S=Uncompress(S,S)
55: S=PackedDigits(S,W)
56: S=UnpackedDigits(S)
continued...
57: S=HexStrToBytes(S,W)
58: S=BytesToHexStr(S)
59: S=XtoBytes(Dw,W)
60: Dw=BytesToX(S)
61: S=TranslateXtoS(S,Dw)
62: Dw=TranslateStoX(S,S)
63: S=TranslateItoS(S,S)
64: S=TranslateStoI(S,S)
65: S=FindStruct(S,S,S)
66: S=GetEnvName()
67: Dw=CountFields()
68: S=FieldByIndex(Dw)
69: S=FieldByName(S)
70: Dw=CountConstants()
71: S=ConstantByIndex(Dw)
72: S=ConstantByName(S)
73: S=ConstantByValue(Dw)
---
74 functions
a='S=VersionString()'
b=''
c='DW=FileSize(S)'
function main()
hxd=dllload(libname);
if(hxd)
print("version: %s\n",dllfunction(hxd,"S=VersionString()","Pascal"));
test_dllfuncs();
dllfree(hxd);
else
print("library '%s' - load failed\n",libname);
endif
endfunction
function test_dllfuncs()
string s=""; integer x=0;
// Debug functions (1)
f("VersionString"); dllfunction(hxd,proto,PAS);
f("ErrorString"); dllfunction(hxd,proto,PAS);
f("ErrorCode"); dllfunction(hxd,proto,PAS);
f("Debug"); dllfunction(hxd,proto,PAS,x,x);
f("PrototypeByIndex"); dllfunction(hxd,proto,PAS,x);
f("PrototypeByName"); dllfunction(hxd,proto,PAS,s);
f("ObsoleteFunction"); dllfunction(hxd,proto,PAS,x);
// File functions (2)
f("UseFileHandle"); dllfunction(hxd,proto,PAS,-1);
f("DataPrefix"); dllfunction(hxd,proto,PAS,s);
f("GotoLine"); dllfunction(hxd,proto,PAS,x);
f("CountLines"); dllfunction(hxd,proto,PAS);
f("CountGroups"); dllfunction(hxd,proto,PAS);
f("CountMsg"); dllfunction(hxd,proto,PAS,x,x,x);
f("SkipLines"); dllfunction(hxd,proto,PAS,x);
f("SkipHexLines"); dllfunction(hxd,proto,PAS,x);
f("SkipHexBlocks"); dllfunction(hxd,proto,PAS,x);
f("SkipMsg"); dllfunction(hxd,proto,PAS,x);
f("ReadLine"); dllfunction(hxd,proto,PAS);
f("ReadHexLines"); dllfunction(hxd,proto,PAS,x,s,x);
f("ReadHexBlocks"); dllfunction(hxd,proto,PAS,x,s,x);
f("ReadMsg"); dllfunction(hxd,proto,PAS,x,s);
f("MsgTime"); dllfunction(hxd,proto,PAS);
f("MsgSndRcv"); dllfunction(hxd,proto,PAS);
f("MsgHdr"); dllfunction(hxd,proto,PAS,x,s);
f("MsgData"); dllfunction(hxd,proto,PAS,s);
f("FindStr"); dllfunction(hxd,proto,PAS,s);
f("FindHex"); dllfunction(hxd,proto,PAS);
f("FindMsg"); dllfunction(hxd,proto,PAS,x);
f("CurLine"); dllfunction(hxd,proto,PAS);
f("StartOfGroup"); dllfunction(hxd,proto,PAS,x);
f("EndOfGroup"); dllfunction(hxd,proto,PAS,x);
f("CountHex"); dllfunction(hxd,proto,PAS,s);
f("FileSeek"); dllfunction(hxd,proto,PAS,x);
f("FileTell"); dllfunction(hxd,proto,PAS);
// Hexadecimal string functions
f("SetHex"); dllfunction(hxd,proto,PAS,s,x,x);
f("GetHex"); dllfunction(hxd,proto,PAS,s,x);
f("ShiftHexLeft"); dllfunction(hxd,proto,PAS,s);
// Bytestring functions
f("GetBytes"); dllfunction(hxd,proto,PAS,s,x,x);
f("SetBytes"); dllfunction(hxd,proto,PAS,s,x,x,s);
f("CountBytes"); dllfunction(hxd,proto,PAS,s);
// Bitfiled functions
f("GetBits"); dllfunction(hxd,proto,PAS,x,x,x,s);
f("SetBits"); dllfunction(hxd,proto,PAS,x,x,x,s,x);
// Binary file functions
f("ReadBin"); dllfunction(hxd,proto,PAS,s,x,x);
f("FileSize"); dllfunction(hxd,proto,PAS,s);
f("ReadTicket"); dllfunction(hxd,proto,PAS,s,x);
f("CountTickets"); dllfunction(hxd,proto,PAS,s);
continued...
// String functions
f("StringFrom"); dllfunction(hxd,proto,PAS,s,x);
f("SkipSpaces"); dllfunction(hxd,proto,PAS,s);
f("TrimEnd"); dllfunction(hxd,proto,PAS,s);
f("WildCompare"); dllfunction(hxd,proto,PAS,s,s);
// Token functions
f("ShiftTokenLeft"); dllfunction(hxd,proto,PAS,s,s);
f("CountTokens"); dllfunction(hxd,proto,PAS,s,s);
f("GetToken"); dllfunction(hxd,proto,PAS,s,s,x);
// Delimiter modifications
f("ChangeDelimiter");dllfunction(hxd,proto,PAS,s,s);
f("Uncompress"); dllfunction(hxd,proto,PAS,s,s);
// Packed digits conversions
f("PackedDigits"); dllfunction(hxd,proto,PAS,s,x);
f("UnpackedDigits"); dllfunction(hxd,proto,PAS,s);
// BigEndian conversions
f("HexStrToBytes"); dllfunction(hxd,proto,PAS,s,x);
f("BytesToHexStr"); dllfunction(hxd,proto,PAS,s);
f("XtoBytes") ; dllfunction(hxd,proto,PAS,x,x);
f("BytesToX") ; dllfunction(hxd,proto,PAS,s);
// Translation table functions
f("TranslateXtoS"); dllfunction(hxd,proto,PAS,s,x);
f("TranslateStoX"); dllfunction(hxd,proto,PAS,s,s);
f("TranslateItoS"); dllfunction(hxd,proto,PAS,s,s);
f("TranslateStoI"); dllfunction(hxd,proto,PAS,s,s);
// Field lookup table functions
f("FindStruct"); dllfunction(hxd,proto,PAS,s,s,s);
f("GetEnvName"); dllfunction(hxd,proto,PAS);
f("CountFields"); dllfunction(hxd,proto,PAS);
f("FieldByIndex"); dllfunction(hxd,proto,PAS,x);
f("FieldByName"); dllfunction(hxd,proto,PAS,s);
f("CountConstants"); dllfunction(hxd,proto,PAS);
f("ConstantByIndex"); dllfunction(hxd,proto,PAS,x);
f("ConstantByName"); dllfunction(hxd,proto,PAS,s);
f("ConstantByValue"); dllfunction(hxd,proto,PAS,x);
pause(55);
endfunction