Additional String Library for 8051 is available.
Contain 4 sections (*.mcl file).
"additional_string.mcl"
Code: Select all
{
- Procedure _8051_aditional_string_library_version(var version : string[$FF]);
//return version of library
//Ex. _8051_aditional_string_library_version(data_out);
//data_out will be '8051_A_S_L V1.0 29-Sep-2008'
- procedure Mem_Cpy(pt1, pt2 : ^byte; n : byte);
// copies n bytes starting from memory address pt2 to memory area beginning
// at pt1.
- function Mem_Cmp(pt1, pt2 : ^byte; n : byte): integer;
// compares two memory areas starting at addresses pt1 and pt2 for n bytes
- procedure Mem_Set(pt : ^byte; ch : char; n : byte);
// fills the first n bytes of memory with ch, starting at address pt
- function Mem_Chr(pt : ^byte; ch : byte; n : byte): byte;
// locates the first occurrence of ch in the initial n bytes of memory area
// starting at address pt. Function returns the offset of this occurrence
// from the memory address p or $FF if no str_ance of ch was found.
- function Str_Len(var str_ : string[$FF]) : byte;
// return length of str_
- procedure Str_Cat(var str_1, str_2 : string[$FF]);
// concatenates str_2 to str_1
- procedure Str_Cut_Chr(var str_ : string[$FF]; ch : byte);
// reemoves all characters equal ch from front of the string
- procedure Str_AppendSuf(var str_ : string[$FF]; ch : char);
// adds ch at the end of str_
- procedure Str_AppendPre(var str_ : string[$FF]; ch : char);
// inserts ch at the beginning of str_
- function Str_Chr(var str_ : string[$FF]; ch : char) : byte;
// returns the position (index) of the first character ch found in s;
// if no matching character was found, function returns $FF;
// the null character terminating str_ is included in the search.
- procedure Str_Cpy(var str_1, str_2 : string[$FF]);
// copies str_2 to str_1
- procedure Str_Replace_Chr(var str_ : string[$FF]; ch1, ch2 : char);
// replaces all occurences of ch1 with ch2 in str_
- procedure Str_Split(var str_1, str_2 : string[$FF]; n : byte);
// Split str_1 in 2 strings after n char
- procedure Str_Insert_Chr(var str_1 : string[$FF]; chr_ : byte; n : byte);
// Insert Chr at position n
- procedure Str_CutLeft(var str_ : string[$FF]; n : byte);
// remove first n char at beginning of str_
- procedure Str_CutRight(var str_ : string[$FF]; n : byte);
// remove last n char at the end of str_
}
Code: Select all
{
- Procedure LongWord2StrWithZeros(data_in : longint; var data_Str : String[10]);
// Convert LongWord value to String[10].(for next release)
// Ex. LongWord2StrWithZeros(11645, data1); // data1 will be '0000011645'
- Procedure Word2StrWithZeros(data_in : word; var data_Str : String[5]);
// Convert word value to String[5].
// Ex. Word2StrWithZeros(645, data1); // data1 will be '00645'
- Procedure Byte2StrWithZeros(data_in : byte; var data_Str : String[3]);
// Convert byte value to String[3].
// Ex. Byte2StrWithZeros(10, data1); // data1 will be '010'
- Procedure LongInt2StrWithZeros(data_in : longint; var data_Str : String[11]);
// Convert longint value to String[11].
// Ex. LongInt2StrWithZeros(-11645, data1); // data1 will be '-0000011645'
- Procedure Int2StrWithZeros(data_in : integer; var data_Str : String[6]);
// Convert integer value to String[6].
// Ex. Int2StrWithZeros(-645, data1); // data1 will be '-00645'
- Procedure Short2StrWithZeros(data_in : short; var data_Str : String[4]);
// Convert short value to String[4].
// Ex. Short2StrWithZeros(-10, data1); // data1 will be '-010'
- Procedure Short2Str(data_in : short; var data_Str : String[4]);
// Convert short value to String, lenght of String is variable from 1 to 4.
// Ex. Short2Str(-10, data1); // data1 will be '-10'
- Procedure Int2Str(data_in : integer; var data_Str : String[6]);
// Convert integer value to String, lenght of String is variable from 1 to 6.
// Ex. Int2Str(-645, data1); // data1 will be '-645'
- Procedure LongInt2Str(data_in : longint; var data_Str : String[10]);
// Convert longint value to String, lenght of String is variable from 1 to 11.
// Ex. LongInt2Str(-11645, data1); // data1 will be '-11645'
- Procedure Byte2Str(data_in : byte; var data_Str : String[3]);
// Convert byte value to String, lenght of String is variable from 1 to 3.
// Ex. Byte2Str(10, data1); // data1 will be '10'
- Procedure Word2Str(data_in : word; var data_Str : String[5]);
// Convert word value to String, lenght of String is variable from 1 to 5.
// Ex. Word2Str(645, data1); // data1 will be '645'
- Procedure LongWord2Str(data_in : longint; var data_Str : String[10]);
// Convert LongWord value to String, lenght of String is variable from 1 to 10. (for next release)
// Ex. LongWord2Str(11645, data1); // data1 will be '11645'
- Procedure Float2Str(data_in : Real; var data_Str : String[17]; digits : byte);
// Convert Real value to String, lenght of String is variable from 1 to 17, max digits 4.
// Ex. Float2Str(-116.12345, data1, 0); // data1 will be '-116'
// Ex. Float2Str(-116.12345, data1, 3); // data1 will be '-116.123'
// Ex. Float2Str(-116.12345, data1, 4); // data1 will be '-116.1234'
- Procedure Float2Str_5(data_in : Real; var data_Str : String[17]; digits : byte);
// Convert Real value to String, lenght of String is variable from 1 to 17, max digits 5.
// Ex. Float2Str(-116.12345, data1, 0); // data1 will be '-116'
// Ex. Float2Str(-116.12345, data1, 3); // data1 will be '-116.123'
// Ex. Float2Str(-116.12345, data1, 5); // data1 will be '-116.12345'
- Procedure Byte2Hex(data_hex : byte; var hex : String[2]);
//Convert Byte to Hex
//Ex. Byte2Hex(255,data_out);
- Procedure Word2Hex(data_hex : word; var hex : String[4]);
//Convert Word to Hex
//Ex. Word2Hex(255,data_out);
}
"additional_string2val.mcl"
Code: Select all
{
- Function Hex2Byte(var hex : String[2]) : byte;
//Convert Hex String format (must be String[2]) into Byte
//Ex. res_8 := Hex2Byte('AA');
- Function Hex2Word(var hex : String[4]) : word;
//Convert Hex String format (must be String[4]) into Word
//Ex. res_16 := Hex2Word('AA55');
- Function Str2Byte(var byte_in : String[3]) : byte;
//Convert Byte String format (must be String[1] to String[3]) into Byte
//Ex. res_8 := Str2Byte('6');
//Ex. res_8 := Str2Byte('66');
//Ex. res_8 := Str2Byte(' 66');
//Ex. res_8 := Str2Byte(' 6');
- Function Str2Short(var byte_in : String[4]) : short;
//Convert Short String format (must be String[1] to String[4]) into short
//Ex. res_8s := Str2Short('-6');
- Function Str2Word(var word_in : String[5]) : word;
//Convert Word String format (must be String[1] to String[5]) into Word
//Ex. res_16 := Str2Word('9');
//Ex. res_16 := Str2Word(' 669');
//Ex. res_16 := Str2Word('96');
//Ex. res_16 := Str2Word(' 669');
- Function Str2Int(var word_in : String[6]) : integer;
//Convert Word String format (must be String[1] to String[6]) into integer
//Ex. res_16s := Str2Int('-12345');
- Function Str2LongWord(var byte_in : String[10]) : longint;
//Convert LongWord String format (must be String[1] to String[10]) into longint.(for next release)
//Ex. res_32 := Str2LongWord('1234567890');
- Function Str2LongInt(var byte_in : String[11]) : Longint;
//Convert Longint String format (must be String[1] to String[11]) into Longint
//Ex. res_32s := Str2dLong('-1234567890');
- Function Str2Float(var byte_in : String[17]) : real;
//Convert Float String format (must be String[1] to String[17]) into Float, sign + 10bytes + '.' + 5 bytes
//Ex. res_float := Str2Float('-123.12345');
}
Code: Select all
{
- Procedure IP2Str(var user_IPaddr : array[4] of byte; var Str_out : String[15]);
//Convert IP ( array[4] of byte ) into String. Lenght of String is variable from 7 to 15.
//Ex. IP2Str(IP_address,data_out);
- Procedure MAC2Str(var MAC_address : array[6] of byte; var Str_out : String[12]);
//Convert MAC ( array[6] of byte ) into String[12].
//Ex. MAC2Str(MAC_address, data_out);
- Procedure Str2IP(var Str_in : String[15]; var user_IPaddr : array[4] of byte);
//Convert String (lenght of String must be from 7 to 15 and must include 3 '.') to array[4] of byte
//Ex. Str2IP('192.168.1.155', IP_address);
- Procedure Str2MAC(var Str_in : String[12]; var MAC_address : array[6] of byte);
//Convert String (lenght of String must be 12) to array[6] of byte
//Ex. Str2MAC('00AA80FF457F', MAC_address);
- Procedure Str2IP_(var Str_in : String[15]; res_IP_addr : ^byte);
//Convert String (lenght of String must be from 7 to 15 and must include 3 '.') to array[4] of byte
//Ex. Str2IP('192.168.1.155', IP_address);
- Procedure Str2MAC_(var Str_in : String[12]; res_MAC_addr : ^byte);
//Convert String (lenght of String must be 12) to array[6] of byte
//Ex. Str2MAC('00AA80FF457F', MAC_address);
}
http://www.microelemente.ro/MikroPascal ... ibrary.zip
Enjoy !