TEIMSI
Developer's platform of programming text codes
Home|Utilities|Forum|Documentation

Table of contents -> Chapter 13 - Functions to get and show information


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

1)- alert(string)

2)- alert_ex(string,titulo,banderas)

3)- cmdline()

4)- err_description(number)

5)- err_number()

6)- ibsize(variable)

7)- imode(variable)

8)- inputdlg(title,caption_text,default_input_string)

9)- inputdlgx(title,caption_text,default_input_string)

10)- iofix(variable)

11)- ipointer(variable)

12)- itype(variable)

13)- number_type(number_inside_text)

14)- timelong(boolean)

15)- opfopen(path,text,extensions)

16)- opfsave(path,text,extensions)

17)- timelong2arr(integer)

18)- arr2timelong(array)




alert

The "alert" function displays a message in a simple dialog with a button to accept. (Equivalent to the MessageBox function of the library user32.dll).


Syntax
alert(string)
 

Parameters
string
TEIMSI variable with a data type of string.
 

Returned value
(none)
 

Example:



	alert("Hello")


See also <<alert_ex>>


Go to top

alert_ex

The "alert_ex" function displays a message title, icon and buttons. (Equivalent to the MessageBox function of the library user32.dll).


Syntax
alert_ex(message,title,flags)
 

Parameters
message
TEIMSI variable with a data type of string.
 
title
TEIMSI variable with a data type of string.
 
flags
TEIMSI variable with data type of a 32 bits integer number. The following predefined variables can be used to form this number (with successive additions):
 


		_mb_okcancel
		_mb_abortretryignore
		_mb_yesnocancel
		_mb_yesno
		_mb_retrycancel
		_mb_iconerror
		_mb_iconquestion
		_mb_iconexclamation
		_mb_iconinformation
		_mb_iconasterisk
		_mb_defbutton2
		_mb_defbutton3

	

Returned value
integer_number
TEIMSI variable with data type of a 32 bits integer number. The following predefined variables can have their value:
 


		_mbret_yes
		_mbret_no
		_mbret_cancel
		_mbret_yesno
		_mbret_abort
		_mbret_retry
		_mbret_ignore

	

Example:



	var rs=alert_ex("Select an option:","Example of alert_ex:",_mb_iconquestion+_mb_yesnocancel)
	
	var rsarr=array()
		rsarr[_mbret_cancel]="Cancel"
		rsarr[_mbret_yes]="Yes"
		rsarr[_mbret_no]="No"
	
	alert("It was choosen : " + rsarr[rs])


See also <<alert>>


Go to top

cmdline

The "cmdline" function returns the command line that was passed to the program when it was started. The string offered may have different forms of representation; in general it is the path to the program in quotes followed by a space and the line of additional commands.


Syntax
cmdline()
 

Parameters
(none)
 

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

Example:



	alert(cmdline())


See also <<alert>>


Go to top

err_description

The "err_description" function receives a number of error returned by the major APIs Win.2000/XP/7/... (kernel32, user32, Etc.) and returns the description of the error.


Syntax
err_description(integer_number)
 

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

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

Example:



	deletefile("unfound.unfound")

	alert(err_description(err_number()))		//	Shows the error "The system can not find the specified file."

	_direct{
		invoke SetLastError, 28	;	Sets the error that there is no paper in the printer.
	}		

	alert(err_description(err_number()))

	// (Remark: The file "win_errores.txt" within the "tools" folder with the Editor TEIMSI contains a list of Win.2000/XP/7/... system errors.)


See also <<err_number>>


Go to top

err_number

The "err_number" function returns the last error generated by some function of API's main Win.2000/XP/7/... (libraries kernel32, user32, Etc.).


Syntax
err_number()
 

Parameters
(none)
 

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

Example:


	(see the example of the "err_description" function.)



See also <<err_description>>


Go to top

ibsize

The "ibsize" function returns the length of the inner block of data inside an array or string. If it is a string size of said block is generally somewhat larger than the string size.


Syntax
ibsize(string)
 
ibsize(array)
 

Parameters
string/array
TEIMSI variable with data type of string or array.
 

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

See also <<imode>>


Go to top

imode

The "imode" function returns an integer that tells the modality of a variable. For more information see chapter "TEIMSI Variables".


Syntax
imode(TEIMSI_variable)
 

Parameters
TEIMSI_variable
TEIMSI variable of any type.
 

Returned value
integer_number
TEIMSI variable with data type of a 32 bits integer number. The mode/modality is a property of variables and it's present in the "regvar" structure of every TEIMSI variable. The following predefined variables can be used to evaluate this result.
 


		(Constant)		(Mode of the variable)

		_mod_stat		Static.
		_mod_dina		Dynamic (for variables declared with "var")
		_mod_engi		Temporal (for not declared variables)

	

Example:



	var amount=3
	alert("The \"amount\" variable was declared with var = "+ (imode(amount)==_mod_dina));
	alert("The static variable was declared with var = "+ (imode("text")==_mod_dina));



See also <<itype>>


Go to top

inputdlg

The "inputdlg" function displays a dialog box with a title, message, a text box and accept and cancel buttons. It allows entering text from the user.


Syntax
inputdlg(title, text, default_string)
 

Parameters
title
TEIMSI variable with a data type of string. Title of the dialog box.
 
text
TEIMSI variable with a data type of string. Description text for the dialog box.
 
default_string
TEIMSI variable with a data type of string. It's the default text that appears on the text box.
 

Returned value
string/boolean
TEIMSI variable with a data type of string.
 
Remark: In order to be able to use this function it's necessary to include the internal data structure of the dialog box inside the resource data section, which can be done including the file "simple_rsrc.asm" using the instruction "includec(engine\internal\simple_rsrc.asm)" (see example below).
 

Example:



	//	The following program allows to input a number and returns the inverse of it.

	includec(engine\internal\simple_rsrc.asm)
	var sint="10.7"
	while(true){
		var sint=inputdlg("Input any integer:", "<Calculation of the Inverse>", sint)
		if(sint===false){break}
		alert_ex("The inverse of " + sint + ", is : " + (1/parsefloat(sint)), "Information", _mb_iconinformation)
	}


See also <<parsefloat>>


Go to top

inputdlgx

The "inputdlgx" function behaves like the "inputdlg" function but characters are hidden in the text box. (Displays a dialog box with a title, message, a text box and button accept and cancel;. Allowing the user to input text)


Syntax
inputdlgx(title, text, default_string)
 

Parameters
title
TEIMSI variable with a data type of string. Title of the dialog box.
 
text
TEIMSI variable with a data type of string. Description text for the dialog box.
 
default_string
TEIMSI variable with a data type of string. It's the default text that appears on the text box.
 

Returned value
string/boolean
TEIMSI variable with a data type of string.
 
Remark: In order to be able to use this function it's necessary to include the internal data structure of the dialog box inside the resource data section, which can be done including the file "simple_rsrc.asm" using the instruction "includec(engine\internal\simple_rsrc.asm)" (see example below).
 

Example:



	includec(engine\internal\simple_rsrc.asm)
	var keyword=inputdlgx("<Data>","Input the keyword:", "keywordkeywordkeywordkeyword")
	alert("The keyword entered is : " +keyword)


See also <<inputdlg>>


Go to top

iofix

The "iofix" function returns an integer with the internal handle of the string or array that is passed as a variable.


Syntax
iofix(string)
 
iofix(array)
 

Parameters
string/array
TEIMSI variable with data type of string or array.
 

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

Example:


	// The following example shows two ways to reach the handle of a string or array.

	var string=ucase("hello!")+chr(0)		// Creates a string variable.

	var handle1=0			// Creates a long integer variable.
	_direct{
		mov eax, [string+reg.vo]		;	It loads the handler.
		mov [handle1+reg.vo], eax	;	Stores the value in the integer value "handle1". 
	}
	var handle2=iofix(string)	// "iofix" performs the same task but in another way.

	alert("handlers are the same = " + (handle1==handle2))

	// Shows the string using "MessageBox"

	_direct{
		mov eax, [handle2+reg.vo]
		NWPOS_eax
		invoke MessageBox, 0, esi, (tsi_msgxtitile), 0
	}


See also <<imode>>, <<itype>>


Go to top

ipointer

The "ipointer" function returns an integer type TEIMSI variable with the address in memory (accessed by the microprocessor) that points to the string or array variable that is passed as a parameter.


Syntax
ipointer(string)
 
ipointer(array)
 

Parameters
string/array
TEIMSI variable with data type of string or array.
 

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

See also <<iofix>>


Go to top

itype

The "itype" function returns an integer indicating the type of data that a variable has.


Syntax
itype(variable)
 

Parameters
variable
TEIMSI variable of any type.
 

Returned value
integer_number
TEIMSI variable with data type of a 32 bits integer number. The following predefined variables can be used to evaluate this result.
 


			_sysbool        Boolean
			_syslong        Integer with size of 32 bits
			_sysdbl         Floating point precision number (uses 8 bytes)
			_sysstr         String
			_sysarr         Array
			_sysundef       "Undefined"
			_sysnull        "Null"
	

Example:


	var number=19.2
	alert("Is \"number\" a variable with a floating point value ? : " + (itype(number)==_sysdbl))


See also <<imode>>


Go to top

number_type

The "number_type" function describes the type of number that a string expression has.


Syntax
number_type(string)
 

Parameters
string
TEIMSI variable with a data type of string.
 

Returned value
integer_number
TEIMSI variable with data type of a 32 bits integer number. This result indicates 0 if not a number, 1 if it is an integer and 2 if it is a floating point number. The following predefined variables: _numtype_long, _numtype_dbl, _numtype_none; have the values 1, 2 and 0 respectively, and can be used to evaluate this result.
 

Example:



	alert("82.3 is a decimal number? =" + (number_type("82.3")==2))



See also <<parsefloat>>


Go to top

timelong

The "timelong" function returns the current time on a 32-bit integer with seconds since 1/1/1970. The information is comparable with the known "Linux Time". The parameter that is passed is a boolean (or integer of 1 or 0 value) indicating "true" if you want to get the time in UTC 0 (time according to Greenwich Mean Time), otherwise the time is returned in the time zone of the operating system.


Syntax
timelong(boolean)
 

Parameters
boolean
TEIMSI variable with data type of a 32 bits integer number. It indicates "true" if the current time is to be in the meridian of Greenwich.
 

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

See also <<timelong2arr>>


Go to top

opfopen

The "opfopen" function opens a dialog box to enter the name of a file to be read.


Syntax
opfopen(path,text,extensions)
 

Parameters
path
TEIMSI variable with a data type of string. It indicates the default path when selecting a file.
 
text
TEIMSI variable with a data type of string. It indicates the title of the dialog box, if a "" (null string) is specified, the default title will be taken.
 
extensions
TEIMSI variable with a data type of string. It indicates the text to show to the user for the allowed file extensions, followed by a chr(0) character and the allowed extensions in the format: *.extensions (for example "*.*" indicates all the file extensions).
 

Returned value
string
TEIMSI variable with a data type of string. The null string ("") will be returned in case that no file is selected.
 

Example:



	var r = opfopen(".","","all files *.*"+chr(0)+"*.*");
	alert("It was choosen : " + r)



See also <<opfsave>>


Go to top

opfsave

The "opfsave" function opens a dialog box to enter the name of a file you want to write or save.


Syntax
opfsave(path,text,extensions)
 

Parameters
path
TEIMSI variable with a data type of string. It indicates the default path when selecting a file.
 
text
TEIMSI variable with a data type of string. It indicates the title of the dialog box, if a "" (null string) is specified, the default title will be taken.
 
extensions
TEIMSI variable with a data type of string. It indicates the text to show to the user for the allowed file extensions, followed by a chr(0) character and the allowed extensions in the format: *.extensions (for example "*.*" indicates all the file extensions).
 

Returned value
string
TEIMSI variable with a data type of string. The null string ("") will be returned in case that no file is selected.
 

Example:



	var r = opfsave(".","","all files *.*\0*.*");
	alert("It was choosen : " + r)



See also <<opfopen>>


Go to top

timelong2arr

The "timelong2arr" function receives an integer with the amount of seconds since 1/1/1970 (see "timelong") and returns an array with integers that describe the date precisely.


Syntax
timelong2arr(integer_number)
 

Parameters
integer_number
TEIMSI variable with data type of a 32 bits integer number. It must be a number in the format and information of integers returned by the "timelong" function.
 

Returned value
array
TEIMSI variable with a data type of array. The following table shows predefined variables that can be used to evaluate the data of such array.
 


		_tlyear          Year of the date.
		_tlmonth         Month of the date.
		_tldayofweek     Day of the week, (0=sunday, 1=monday, ...) of the date.
		_tlday           Month day of the date.
		_tlhour          Hour of the date.
		_tlminute        Minute of the date.
		_tlsecond        Second of the date.
	

Example:



var arrdate=timelong2arr(timelong(false))

alert("The current hour = "+arrdate[_tlhour])



See also <<arr2timelong>>


Go to top

arr2timelong

The "arr2timelong" function receives an array with the same format returned by the "timelong2arr" function and returns an integer seconds since 1/1/1970. The item of _tldayofweek index (index 2) is ignored.


Syntax
arr2timelong(array)
 

Parameters
array
TEIMSI variable with a data type of array. (see table that shows predefined variables to evaluate it's data in the help of the "timelong2arr" function.)
 

Returned value
integer_number
TEIMSI variable with data type of a 32 bits integer number with the seconds since 1/1/1970.
 

var arrdate=array(1997,4,0,17,23,15,0)

alert("Elapsed seconds from January 1th of 1970 at 00:00',0\", to April 17th of 1997 at 17:23',15\" = " + arr2timelong(arrdate))


See also <<timelong2arr>>


Go to top