TEIMSI
Developer's platform of programming text codes

The next topic is the description for the use of the following predefined TEIMSI functions:

1)- binstrpack

2)- binstrunpack

3)- floatpack

4)- floatunpack

5)- longpack

6)- longunpack

7)- parsefloat

8)- parseint

9)- parsestr

10)- copyof

11)- iftrue

# binstrpack

The "binstrpack" function, converts a string in another eight times larger than contains the representation of each bit that makes up the bytes of the original. The characters in the returned string may be only one of two values: chr(0) and chr(1), which have ASCII code 0 and 1 respectively.

Syntax
 binstrpack(string)

Parameters
 string TEIMSI variable with a data type of string.

Returned value
 string TEIMSI variable with a data type of string.

Example:

```

//	The following example shows the string "00000000000100000000000000000100", that represents the bytes (0,0,0,0,0,1,0,0, 0,0,0,0,0,0,1,0), this is because the character " "=chr(32)= 00100000 at binary and chr(64)=01000000 in binary system, writing in hexadecimal numerical system the characters chr(0) y chr(1) of the value of each bit of the characters chr(32) y chr(64) joined, you obtain the shown string.

```

Go to top

# binstrunpack

The "binstrunpack" function, receives a string with length multiple of eight that has only characters chr(0) and chr(1) (which have code ASCII 0 and 1 respectively) and converts it into a string of eighth of its size that has the bytes whose bits are what represent the bytes of the input string. In other words, does the reverse task of the "binstrpack" function.

Syntax
 binstrunpack(string)

Parameters
 string TEIMSI variable with a data type of string.

Returned value
 string TEIMSI variable with a data type of string.

Example:

```

//	The following example shows the string "[>" ,  "[" = chr(91), ">" = chr(62):  We can see that 91 = 01011011 binary  y  62 = 00111110 binary.

var uarr=array(1,1,0,1,1,0,1,0,  0,1,1,1,1,1,0,0)
var binstr=""
for(var t=0;t<count(uarr);t++){
binstr+=chr(uarr[t]);
}

```

Go to top

# floatpack

The "floatpack" function, converts a variable with a floating point number into a string of eight bytes whose information represents the original number. You can get the original number by sending the resulting string to the "floatunpack" function.

Syntax
 floatpack(decimal_number)

Parameters
 decimal_number TEIMSI variable with data type of floating point number.

Returned value
 string String type variable with a length of eight bytes.

Example:

```

var number= 10.46
var string8bytes = floatpack(number)
alert("Length of the resulting string = " + len(string8bytes) +" bytes.")	//	It shows that it has 8 bytes long.

```

Go to top

# floatunpack

The "floatunpack" function, performs the inverse conversion to that performed by the "floatpack" function.

Syntax
 floatunpack(string_8_bytes_long)

Parameters
 string_8_bytes_long String type variable with a length of eight bytes generated by the "floatpack" function.

Returned value
 decimal_number TEIMSI variable with data type of floating point number.

Example:

```

var number= 10.46
var string8bytes = floatpack(number)
var original_number = floatunpack(string8bytes)

```

Go to top

# longpack

The "longpack" function, converts a variable with TEIMSI 32 bit integer, into a four-byte string whose information represents the original number. You can get the original number by sending the resulting string to the "longunpack" function.

Syntax
 longpack(integer_number)

Parameters
 integer_number TEIMSI variable with data type of a 32 bits integer number.

Returned value
 string String type variable with length of four bytes.

Example:

```

var number= 10123
var string4bytes = longpack(number)
alert("Length of the output string= " + len(string4bytes) +" bytes.")	//	It shows that it has 4 bytes long.

```

Go to top

# longunpack

The "longunpack" function, performs the inverse conversion to that performed by the "longpack" function.

Syntax
 longunpack(string_4_bytes_long)

Parameters
 string_4_bytes_long String type variable with length of four bytes generated by the "longpack" function.

Returned value
 integer_number TEIMSI variable with data type of a 32 bits integer number.

Example:

```

var number= 10123
var string4bytes = longpack(number)
var original_number = longunpack(string4bytes)

alert("Original number = " + original_number)

```

Go to top

# parsefloat

The "parsefloat" function tries to convert a string representing a number, to a double precision number variable.

Syntax
 parsefloat(String_That_Represents_a_Number)

Parameters
 String_That_Represents_a_Number TEIMSI variable with a data type of string, it contains the number.

Returned value
 decimal_number TEIMSI variable with data type of floating point number.

Example:

```

```

Go to top

# parseint

The "parseint" function attempts to convert a string that represents an integer number, into a TEIMSI variable with data type of a 32 bits integer number.

Syntax
 parseint(string_that_represents_an_integer_number)

Parameters
 string_that_represents_an_integer_number TEIMSI variable with a data type of string, it contains the number.

Returned value
 integer_number TEIMSI variable with data type of floating point number.

Example:

```

//	"parseint" supports integer of 32 bits in binary and hexadecimal numerical system.

alert(parseint("11001y"))		//	Shows the integer 25, because it's equivalent to the number 11001 in the binary numerical system.

alert(parseint("100h"))		//	Shows the integer 256, because it's equivalent to the number 100 in the hexadecimal numerical system.

```

Go to top

# parsestr

The "parsestr" function converts a TEIMSI variable into a TEIMSI variable with a data type of string.

Syntax
 parsestr(TEIMSI_variable)

Parameters
 TEIMSI_variable TEIMSI variable of any type.

Returned value
 string TEIMSI variable with a data type of string.

Example:

```

var unknown= parsestr(345)

alert("The variable \"unknown\" has a string  = " + (itype(unknown)==_sysstr)  );

var unknown2= parsestr(true)

alert("The variable \"unknown2\" has a string  = " + (itype(unknown2)==_sysstr)  );

```

Go to top

# copyof

The "copyof" function returns a copy of a variable. Fulfills the same function of the declaration set value (with the equal sign "="). Used by certain functions that do not support static string as a parameter.

Syntax
 copyof(TEIMSI_variable)

Parameters
 TEIMSI_variable TEIMSI variable of any type.

Returned value
 TEIMSI_variable TEIMSI variable with the same data of the input parameter.

Example:

```

```

Go to top

# iftrue

The "iftrue" function receives three parameters where the first one is a boolean that decides if the function returns the second parameter or third parameter.

Syntax
 iftrue(Boolean, TEIMSI_variable1, TEIMSI_variable2)

Parameters
 Boolean TEIMSI variable with type of Boolean. TEIMSI_variable1 TEIMSI variable of any type. TEIMSI_variable2 TEIMSI variable of any type.

Returned value
 TEIMSI_variable TEIMSI variable with the same data of the input parameter.

Example:

```

alert(iftrue(5>3, "5 is greater than 3", "5 is less or equal than 3"))

```