You are on page 1of 57

HEXDATA.DOC version 1.

7-0
16-Jan-1998

Introduction

The HEXDATA.DLL library is used to extend built-in library functions of


HIT. The library is mainly targetted for the module testing environment where
message sequences of various types are needed to be built, and sent to the
testbench (kantokoski). The library provides functions for read of hexadecimal
data from files into string variables.

Definition of a message monitoring record

The record consist of a header (3 lines) and the message data:

1. MONITORING TIME
2. RECEIVED/SENT BY
3. MONITORED MESSAGE
4. MESSAGE DATA (can also be empty)

Example of a message monitoring record:


MONITORING TIME: 1994-04-18 01:31:34.46
SENT BY: 01B0 0000 00
MONITORED MESSAGE: 0037 4405 00DA 0000 00 11 0000 0995 0000
08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 58 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00

Definition of a message group


The group consists of consecutive message monitoring records that are
separated by empty lines. The group ends either at the end of the file, or an
non-empty line that contains some other text than the string “MONITORING
TIME: “. The file consist of several message groups, when monitoring has been
collected from several active units (ex. all WO-units of CCSU).

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

Example of some datablocks


00 11 22 33 4444 55 66
00,11,22,33-0000-1111-222222222
dataprefix: 00 , 11 , 22 , 33 , 44
Definition of returned datastring
The data can consist of any combination of bytes,words and dwords. The
library defines two modes for the return string.

• bytes only, mode=0


• structured, mode=1

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 -

*) returns zero if not found, fileposition not moved


UseFileHandle (1.6)
This function initializes the library to use a certain file as workfile. All search
and read operations are performed on the file associated with the filehandle.
The file handle is obtained with the fileopen- function in the HIT-macro. The
workfile is closed using the fileclose()-function in the HIT-macro. Returns the
linenumber (the current fileposition) or zero if a problem occurred.

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

NOTE: item_index starts from zero

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.

Definition of a position triplet


The position triplet consist of startbyte, startbit(0..31), number of bits (1..31)
The entire bitfield must be within the same DWORD as the starting byte

The basic idea is to use the startbyte as an index to the array of


bytes (first byte has index=0). From the selected position the next
four bytes are fetched, forming an DWORD value (bits 0 .. 31).

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

Translation table format 1 (file)


! Example of XS-translation table
!
6034 c_test_msg_s
06035 quit_message_s
0x6036 pr_dl_establish_request

Translation table format 2 (file)


! Example of IS-translation table
!
MSC Mobile Switching Centre
HLR Home Location Register
VLR Visitor Location Register
Field lookup table functions (13)
type Function returns
STR FindStruct(STR filename,STR envname,STR struct) structname string
STR GetEnvName() envname string
DW CountFields() number of ..
STR FieldByIndex(DW index) position triplet
STR FieldByName(STR fieldname) position triplet
DW CountConstants(STR fname,DW line_number) number of ..
STR ConstantByIndex(DW index) constant string
STR ConstantByName(STR name) constant string
STR ConstantByValue(DW value) constant string

NOTE: these functions are likely to be modified in version 1.5-0

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.

Field lookup table format (file)


! Example of field lookup table
!
#EnvName 7.6-0 M6 ! version info, name (M6) is optional

#StructName 6034 c_test_msg_s ! message nr & name /other datatype


0 1 8 test_id ! startbyte, bytesize, bitsize, fieldname
/0 zero_c ! constant value & name
/1 one_c
1 1 8 sub_id
2 128 8 info

#StructName 6431 scd_distribution_ack_s <-- next message


String Buffer functions (14)
type Function Returns
Dw BufferSetByte(S buffer,W ix,Dw Value) New value
BufferSetWord(S buffer,W ix,Dw Value)
BufferSetDword(S buffer,W ix,Dw Value)

Dw BufferGetByte(S buffer,W ix) Value


BufferGetWord(S buffer,W ix)
BufferGetDword(S buffer,W ix)

Dw BufferReadFile(S buffer,W ix,W nbytes) Number of bytes read

Dw BufferWriteFile(S buffer,W ix,W nbytes) Number of bytes


Written
Dw BufferMemMove(S Dest,W ix,S Src,W ix,W nbytes) Number of bytes

Dw BufferMemSet(S buffer,W ix,Dw Value,W nbytes) Number of bytes

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.

The stringbuffer is allocated by declaring a string, and then using strprint()


function to asssign a sufficiently long initial value, to hold the desired binary
object. The contents of the buffer can then be set using the BufferSetX() or
BufferReadFile() functions.

Function Equalent to Description


BufferMemSet .memset / string.h
Initialize memory block
with given value
BufferMemMove .memmove / string.h Copy memory block from
location to another

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

• library handles one open file at time


• library serves one calling application at time.
• HIT-library functions filegetline() and fileread() must be followed by an
explicit setting of the current linenumber with function GotoLine().
• max. string length is 32 000 character
• the string buffer functions allows operations on 64K strings

The getline function can for instance be followed by GotoLine(1), which


moves the filepointer to the beginning of the workfile. The HEXDATA-library
functions works normally after this procedure. Example:
filegetline(hfile,s); // use GotoLine(1) !!!
dllfunction(hxd,"Dw=UseFileHandle(W)","Pascal",hfile); // linenumber=??
dllfunction(hxd,"Dw=GotoLine(Dw)","Pascal",1); // set filepointer
dllfunction(hxd,"S=ReadLine()","Pascal")); // works fine
filegetline(hfile,s); // ok - use GotoLine() again if more calls to DLL
Header file
/***********************************************************************
* *
* HEXDATA.H - function prototypes for HEXDATA-library *
* *
* source code stored in database SATK, subsystem HEXDATA *
***********************************************************************/

/* @(#)MID: HEXDATA.H 1.7-0 98/01/16 */

#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 */

#define STRING const char *


#define VARSTR char *

enum DataModes { BYTES_ONLY=0, STRUCTURED=1 };

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)

hexdata.h 1.1-0 24-apr-96 HEXDATA header file


1.2-0 11-may-96 error codes included
1.3-0 31-Aug-96 string limit increased to 32 kb
1.4-0 31-july-96 dummy freeze to 1.4-0
1.5-0 08-Sep-96 32-bit update for HIT 2.0-b2
1.6-0 16-Sep-97 dummy freeze
1.7-0 16-Jan-98 New: String Buffer functions (14)

hexdata.doc 1.1-0 24-may-96 HEXDATA documentation


1.2-0 24-apr-96 dummy freeze to version 1.2-0
1.3-0 11-may-96 new functions, examples
1.4-0 31-july-96 error codes added, 32k limit
1.5-0 08-Sep-96 32-bit update for HIT 2.0-b2
1.6-0 17-Sep-97 UseFile now documented, TOFE 365703
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

All files are stored in the SATK/HEXDATA database.


List of latest versions can be obtained with command:

$
$ use/database=SATK HEXDATA
%USE-I-NEWSUBSYS, Default subsystem changed to HEXDATA
$ list/vers HEXDATA.*

Current highest versions of modules in subsystem HEXDATA of database SATK

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:

VersionString() --> "@(#)MID: HEXDATA.DLL 1.1-0 96/02/15"

the version info from the SPM system could be used as default

b) the DLL should always contain the Microsoft VERSION-resource

c) the DLL should contain at least one ICON-resource with ID-string

1) "ICON" or
2) "ICON_1"

It is preferable that subsequent versions of the same library


use slightly different ICON to help differentiation between
versions, for instance colors, RED -> GREEN -> BLUE
as the library function evolve.

PROTOTYPE INFORMATION

Two functions are used to return function prototypes:

1) PrototypeByIndex(0) --> "S=VersionString()"


2) PrototypeByName("VersionsString") --> "S=VersionString()"

Return value is empty if function is not found

WRAPPING HIT-MACROS

The wrapping macrofile is included into ohter HIT-macros


using the #include-statement. Wrapping macros takes care of:

1) correct prototype is used


2) correct number of arguments and types are used

CHANGES TO CALLING PARAMETERS

All changes to number of arguments and types are made by


giving the function a new name. The parameter list of a
DLL-function will remain the same after the library
has been published.

REMOVING OBLSOLETE FUNCTIONS ARE NOT ALLOWED

All functions once published, are available even if later on


marked obsolete. Library should support a list of obsolete
functions. Example:

ObsoleteFunction(0) --> "S=LetsDoThisOne(W,DW,S)"

If the library contains too many obsolete functions, the library


should be cleaned and published with an another name.

LIBRARY FUNCTION NAMES

The function names should be:


- descriptive
- unambiguos within the library
- unambiguos with respect to other DLL-librarys
- avoid function names that are (HIT) language keywords

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 test_dllfuncs(integer hfile)


string s,EOF_STR;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,100);
dllfunction(hxd,"Dw=UseFileHandle(W)",Pas,hfile);
EOF_STR=chr(26); // Ctrl-Z
while(1)
s=dllfunction(hxd,"S=ReadLine()",Pas);
if(s==EOF_STR) break; endif // EOF?
printlog(">%s\n",s);
endwhile
printlog(".\n",s);
pause(55);
endfunction
continued...
version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

>line 1: @(#)MID: LINES.TXT 1.2-0 96/05/11


>line 2:
>line 3: example textfile
>line 4: for HEXDATA library
>line 5:
>line 6:
>line 7:
>line 8: message group 1
>
>MONITORING TIME: 1994-04-18 01:31:34.46 // message #1
>RECEIVED BY: 01B0 0000 00
>MONITORED MESSAGE: 0026 4405 00DA 0000 00 01 0000 0994 0004
>11 11 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 58 00 15 FF
>
>MONITORING TIME: 1994-04-18 01:31:34.47 // message #2
>SENT BY: 01B0 0000 00
>MONITORED MESSAGE: 0037 4405 00DA 0000 00 11 0000 0995 0000
>22 22 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 58 00 00 00 00 00 00
>33 33 33 00 00 00 00 00 00 00 00 00 00 00
>
>line 21: message group 2
>
>MONITORING TIME: 1994-04-18 01:31:54.95 // message #3
>RECEIVED BY: 01B0 00DD 00
>MONITORED MESSAGE: 0010 4C38 0138 008A 00 19 0000 6382 006A
>
>
>MONITORING TIME: 1994-04-18 01:31:54.95 // message #4
>SENT BY: 01B0 00DD 00
>MONITORED MESSAGE: 0014 C000 01E8 0001 00 11 0000 5017 0000
>44 44 44 00
>
>MONITORING TIME: 1994-04-18 01:31:54.96 // message #5
>SENT BY: 01B0 00DD 00
>MONITORED MESSAGE: 0014 C000 01E8 0001 00 11 0000 5017 0000
>55 55 55 00
>
>line 38: last line
>
.

Pause: 55 sec. (time: 13:39:04:85)


//
// HEXDAT02.HIT - Read Block from file (2)
//
// @(#)MID: HEXDAT02.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",fname="lines.txt";
const string Pas="Pascal";

const integer BYTES_ONLY=0,STRUCTURED=1;


integer hxd;

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

function test_dllfuncs(integer hfile)


integer lnr;
string s,MM="MONITORED MESSAGE: ",
RXL="S=ReadHexlines(Dw,S,Dw)",
RXB="S=ReadHexBlocks(Dw,S,Dw)";
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
dllfunction(hxd,"Dw=UseFileHandle(W)","Pascal",hfile);
dllfunction(hxd,"S=DataPrefix(S)","Pascal",MM);
s=dllfunction(hxd,"Dw=FindStr(S)","Pascal",MM);
lnr=strtoint(s,DEC); // convert to integer
if(lnr)
printlog("a:%s\n",dllfunction(hxd,RXL,Pas,STRUCTURED,"-",1));
printlog("b:%s\n",dllfunction(hxd,RXB,Pas,BYTES_ONLY," ",1));
else
printlog("string '%s' not found\n",MM);
endif
pause(55);
endfunction
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

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

Pause: 55 sec. (time: 13:39:10:57)


//
// HEXDAT03.HIT - Read Message from file (2)
//
// @(#)MID: HEXDAT03.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",fname="lines.txt";
const string Pas="Pascal";
const integer BYTES_ONLY=0,STRUCTURED=1;

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

function test_dllfuncs(integer hxd,integer hfile)


integer lnr,msg=0x5017,anymsg=0xFFFF;
string s;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
dllfunction(hxd,"Dw=UseFileHandle(W)",Pas,hfile);
s=dllfunction(hxd,"Dw=FindMsg(W)",Pas,msg);
lnr=strtoint(s,DEC); // convert to integer
if(lnr)
printlog("lnr=%d\n",lnr);
printlog("a:%s\n",dllfunction(hxd,"S=MsgTime()" ,Pas));
printlog("b:%s\n",dllfunction(hxd,"S=MsgSndRcv()",Pas));
printlog("c:%s\n",dllfunction(hxd,"S=MsgHdr(DW,S)",Pas,STRUCTURED,","));
printlog("d:%s\n",dllfunction(hxd,"S=MsgData(S)" ,Pas," "));
else
printlog("message %04X not found\n",msg);
endif
pause(55);
endfunction
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

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

Pause: 55 sec. (time: 13:39:16:00)


//
// HEXDAT04.HIT - Count occurrences (2)
//
// @(#)MID: HEXDAT04.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)
test_dllfuncs(hfile);
fileclose(hfile);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction

function test_dllfuncs(integer hfile)


string s;
integer n,msg=0x5017;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
dllfunction(hxd,"Dw=UseFilehandle(W)",Pas,hfile);
s=dllfunction(hxd,"Dw=CountLines()",Pas);
printlog("CountLines=%s\n",s);
s=dllfunction(hxd,"W=CountGroups()",Pas);
printlog("CountGroups=%s\n",s);
s=dllfunction(hxd,"Dw=CountMsg(W,Dw,Dw)",Pas,0xFFFF,1,9999);
printlog("CountMsg(FFFF)=%s\n",s);
s=dllfunction(hxd,"Dw=CountMsg(W,Dw,Dw)",Pas,msg,1,9999);
printlog("CountMsg(%04X)=%s\n",msg,s);
pause(55);
endfunction
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

CountLines=39
CountGroups=2
CountMsg(FFFF)=5
CountMsg(5017)=2

Pause: 55 sec. (time: 13:39:23:47)


//
// HEXDAT05.HIT - Find occurrences (2)
//
// @(#)MID: HEXDAT05.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)
test_dllfuncs(hfile);
fileclose(hfile);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction

function test_dllfuncs(integer hfile)


string s,RDL="S=ReadLine()";
integer n,msg=0x5017,anymsg=0xFFFF;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
dllfunction(hxd,"DW=UseFilehandle(W)",Pas,hfile);
s=dllfunction(hxd,"Dw=FindStr(S)",Pas,"line 4:");
printlog("FindStr=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=FindHex()",Pas);
printlog("FindHex=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=FindMsg(W)",Pas,anymsg); // 0xFFFF
printlog("FindMsg=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
s=dllfunction(hxd,"Dw=FindMsg(W)",Pas,anymsg); // 0x5017
printlog("FindMsg=%s\n",s);
printlog(">%s\n",dllfunction(hxd,RDL,Pas));
pause(55);
endfunction
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

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

Pause: 55 sec. (time: 13:39:30:01)


//
// HEXDAT06.HIT - Skip lines & messages (2)
//
// @(#)MID: HEXDAT06.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)
test_dllfuncs(hfile);
fileclose(hfile);
endif
dllfree(hxd);
else
printlog("library '%s' - load failed\n",libname);
endif
endfunction

function test_dllfuncs(integer hfile)


string s,RDL="S=ReadLine()";
integer n,msg=0x0994;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
dllfunction(hxd,"Dw=UseFilehandle(W)",Pas,hfile);
s=dllfunction(hxd,RDL,Pas); printlog(">%s\n",s);
s=dllfunction(hxd,"Dw=SkipLines(Dw)",Pas,2);
printlog("SkipLines=%s\n",s);
s=dllfunction(hxd,RDL,Pas); printlog(">%s\n",s);

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

>line 1: @(#)MID: LINES.TXT 1.2-0 96/05/11


SkipLines=2
>line 4: for HEXDATA library
FindHex=13 (linenumber)
>11 11 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 58 00 15 FF
SkipHexLines=2
CurLine=19
>33 33 33 00 00 00 00 00 00 00 00 00 00 00
FindMsg(0994)=10 (linenumber)
SkipHexBlocks=2
>line 21: message group 2
SkipMsg=3
>
>MONITORING TIME: 1994-04-18 01:31:54.95 // message #4

Pause: 55 sec. (time: 13:39:45:06)


//
// HEXDAT07.HIT - FileSeek & FileTell (2)
//
// @(#)MID: HEXDAT07.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)
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 test_dllfuncs(integer hfile)


string s,RDL="S=ReadLine()";

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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

FileSeek=3 (line number)


FileTell=52 (byte)
>line 3: example textfile
FileTell=78 (byte)
>line 1: @(#)MID: LINES.TXT 1.2-0 96/05/11

Pause: 55 sec. (time: 13:39:48:47)


//
// HEXDAT08.HIT - Hexadecimal string functions (3)
//
// @(#)MID: HEXDAT08.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";
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;
integer i,n;

a="00 11 22 33 - 0056"; // example string

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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

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=''

Pause: 55 sec. (time: 13:40:00:55)


//
// HEXDAT09.HIT - Bytestring functions (4)
//
// @(#)MID: HEXDAT09.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";

const integer BYTES_ONLY=0,STRUCTURED=1;


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 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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

CountBytes=11
GetBytes=11 22 33
SetBytes=1, x=00 AA BB CC 44 55 66 77 88 99 AA

Pause: 55 sec. (time: 13:40:03:08)


//
// HEXDAT10.HIT - Bitfield functions (5)
//
// @(#)MID: HEXDAT10.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";
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 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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

GetBits=0x5443
SetBits=1, bs=00 11 22 88 99 55 66 77

Pause: 55 sec. (time: 13:40:05:22)


//
// HEXDAT11.HIT - Binary file functions (6)
//
// @(#)MID: HEXDAT11.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",Pas="Pascal";
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 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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

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

Pause: 55 sec. (time: 13:40:08:24)


//
// HEXDAT12.HIT - String functions (7)
//
// @(#)MID: HEXDAT12.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",Pas="Pascal";
integer hxd,N=8;
string tbl[]=
{
// max. 2 degrees of freedom (**)
"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
};

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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

TrimEnd=' tabs and returns'


SkipSpaces='tabs and returns'
StringFrom='and returns'
i=1, wc('abcdef')=1
i=2, wc('abc*')=1
i=3, wc('*def')=1
i=4, wc('*cd*')=1
i=5, wc('a*cd*f')=1
i=6, wc('ab*ef')=1
i=7, wc('*')=1
i=8, wc('ABC*')=0

Pause: 55 sec. (time: 13:40:20:27)


//
// HEXDAT13.HIT - Token functions (8)
//
// @(#)MID: HEXDAT13.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",Pas="Pascal";
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 s,ts,special=",+-*/=";
integer i,n;

ts=" a,b(c,d,\"e f\")+f+g\"a b\" (\"(\"tan(x))+ ";


s=dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);
s=dllfunction(hxd,"Dw=CountTokens(S,S)",Pas,ts,special);
n=strtoint(s,DEC); printlog("CountTokens=%d\n",n);
for(i=0;i<n;i++)
s=dllfunction(hxd,"S=GetToken(S,S,Dw)",Pas,ts,special,i);
printlog("GetToken(%d)='%s'\n",i,s);
endfor
delay(3000); printlog("---\n");
while(ts<>"")
s=dllfunction(hxd,"S=ShiftTokenLeft(S,S)",Pas,ts,special);
printlog("%-12s , ts='%s'\n",s,ts);
endwhile
pause(55);
endfunction
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

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=''

Pause: 55 sec. (time: 13:40:34:93)


//
// HEXDAT14.HIT - Delimiter modifications (9)
//
// @(#)MID: HEXDAT14.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";
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 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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

ChangeDelimiter=00,11,22,33,44
Uncompress=12,34,56

Pause: 55 sec. (time: 13:40:37:35)


//
// HEXDAT15.HIT - Packed digits conversions (10)
//
// @(#)MID: HEXDAT15.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";
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 s;
dllfunction(hxd,"Dw=Debug(Dw,Dw)",Pas,1,500);

// filldigit used for odd number of digits


s=dllfunction(hxd,"S=PackedDigits(S,W)",Pas,"1234567",0xF);
printlog("PackedDigits=%s\n",s);

s=dllfunction(hxd,"S=UnPackedDigits(S)",Pas,s);
printlog("UnPackedDigits=%s\n",s);

// not used for even number of digits


s=dllfunction(hxd,"S=PackedDigits(S,W)",Pas,"1234",0xF);
printlog("PackedDigits=%s\n",s);

s=dllfunction(hxd,"S=UnPackedDigits(S)",Pas,s);
printlog("UnPackedDigits=%s\n",s);
pause(55);
endfunction
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

PackedDigits=214365F7
UnPackedDigits=1234567F
PackedDigits=2143
UnPackedDigits=1234

Pause: 55 sec. (time: 13:40:42:18)


//
// HEXDAT16.HIT - BigEndian conversions (11)
//
// @(#)MID: HEXDAT16.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";
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()
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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

HexToBytes=45 23 01 00
BytesToHexStr=0000012345
XtoBytes=45 23 01 00
BytesToX=00012345

Pause: 55 sec. (time: 13:40:47:13)


//
// HEXDAT17.HIT - Translation table functions (12)
//
// @(#)MID: HEXDAT17.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll";
const string Pas="Pascal";

const integer BYTES_ONLY=0,STRUCTURED=1;


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 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
________________________

version: @(#)MID: HEXDATA.CPP 1.3-0 96/05/11

XtoS=AIF program block


XtoS=USAPRO - supervision process
XtoS=console process
StoX=132
StoI=HLR
ItoS=Home Location Register

Pause: 55 sec. (time: 13:40:52:62)


//
// HEXDAT18.HIT - Field lookup table functions (13)
//
// @(#)MID: HEXDAT18.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",Pas="Pascal";
integer hxd;

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'

Pause: 55 sec. (time: 13:40:59:21)


//
// HEXDAT19.HIT - Prototype functions (1)
//
// @(#)MID: HEXDAT19.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",Pas="Pascal";

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)'

Pause: 55 sec. (time: 13:41:01:85)


//
// TESTALL.HIT - Check all DLL prototypes
//
// @(#)MID: TESTALL.HIT 1.2-0 96/05/11
//
const string libname="hexdata.dll",PAS="Pascal";
integer hxd; string proto;

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

function f(string func_name)


proto=dllfunction(hxd,"S=PrototypeByName(S)",PAS,func_name);
if(proto=="") abort(0,func_name); endif
printlog("%s\n",proto);
endfunction
continued...
S=VersionString()
S=ErrorString()
Dw=ErrorCode()
Dw=Debug(Dw,Dw)
S=PrototypeByIndex(Dw)
S=PrototypeByName(S)
S=ObsoleteFunction(Dw)
Dw=UseFileHandle(W)
S=DataPrefix(S)
Dw=GotoLine(Dw)
Dw=CountLines()
Dw=CountGroups()
Dw=CountMsg(W,Dw,Dw)
Dw=SkipLines(Dw)
DW=SkipHexLines(Dw)
Dw=SkipHexBlocks(Dw)
Dw=SkipMsg(Dw)
S=ReadLine()
S=ReadHexLines(Dw,S,Dw)
S=ReadHexBlocks(DW,S,Dw)
S=ReadMsg(Dw,S)
S=MsgTime()
S=MsgSndRcv()
S=MsgHdr(Dw,S)
S=MsgData(S)
Dw=FindStr(S)
Dw=FindHex()
Dw=FindMsg(W)
Dw=CurLine()
Dw=StartOfGroup(Dw)
Dw=EndOfGroup(Dw)
Dw=CountHex(S)
Dw=FileSeek(Dw)
Dw=FileTell()
Dw=SetHex(S,Dw,Dw)
S=GetHex(S,Dw)
S=ShiftHexLeft(S)
S=GetBytes(S,Dw,Dw)
Dw=SetBytes(S,Dw,Dw,S)
Dw=CountBytes(S)
Dw=GetBits(Dw,W,W,S)
Dw=SetBits(Dw,W,W,S,DW)
S=ReadBin(S,Dw,Dw)
Dw=FileSize(S)
S=ReadTicket(S,Dw)
Dw=CountTickets(S)
S=StringFrom(S,Dw)
S=SkipSpaces(S)
S=TrimEnd(S)
Dw=WildCompare(S,S)
S=ShiftTokenLeft(S,S)
Dw=CountTokens(S,S)
S=GetToken(S,S,Dw)
S=ChangeDelimiter(S,S)
S=Uncompress(S,S)
S=PackedDigits(S,W)
S=UnpackedDigits(S)
S=HexStrToBytes(S,W)
S=BytesToHexStr(S)
S=XtoBytes(Dw,W)
Dw=BytesToX(S)
S=TranslateXtoS(S,Dw)
Dw=TranslateStoX(S,S)
S=TranslateItoS(S,S)
S=TranslateStoI(S,S)
S=FindStruct(S,S,S)
S=GetEnvName()
Dw=CountFields()
S=FieldByIndex(Dw)
S=FieldByName(S)
Dw=CountConstants()
S=ConstantByIndex(Dw)
S=ConstantByName(S)
S=ConstantByValue(Dw)

Pause: 55 sec. (time: 13:41:07:39)

You might also like