This translation is older than the original page and might be outdated.




Macros of systems used at mappings.xml level.
A macro serves to replace an specific value in execution time.


In this section we are going to see three types of macros:

  1. COLL level Macros.
  2. ASFILTER level Macros.
  3. APPDATA.FAILWITHMESSAGE level Macros.




All this level macros are used at SQL level, in the FILTERS of the Collections, in the FILTER of the link PROP, and anywhere in the mappongs, but in the ASFILTER node of the collections, neither are they valid to use them in the Script declared in the mappings.
They are valid as much as PC level as much PDA and WEB.



MACROS MACROS DESCRIPTION
##ENTID## Macro that has the value of the ID of the Company with which we enter into the program. To be able to enter in the program an user and a company are needed. The user is associated to that Company, which has an ID in a table, and it is saved in the macro. That macro is used at SQL level, for instance, to get the data of the different tables, for the company that enters in the program.
##ENTIDCOLL##Has the value of the ID of the Program Company, and the companies related to that. The relation is through the IDPADRE field of the GEN_EMPRESAS table. So this macro takes value from the companies that have the ID of the Company with which we enter into the program , and the companies daughters of that companies.
##ENTIDOWNER##Has the value of the ID of the Company with which we enter into the program and the companies superiors to it.
##ENTIDLEVEL##Has the value of the ID of the company with which we enter into the program and the companies that are at the same level.
##USERID##This macro has the value of the user with which we enter into the program.
##USERIDCOLL##It has the ID value of the user with which we enter into the application, and the users related to it. The relation is made through the IDPADRE field of the GEN_USUARIOS table. A PROP would be created in the users collection, that links with the same collection.
##PREF##Macro having the “GEN_” value. This value is given in the Framework, both PC, as PDA. It is used to not have to put the “Gen_” value in the SQL. This doesn´t mean that the tables have to start with Gen_, the database tables can be called in any way. We use it because we have generic databases for different clients, being able to use the same database in different projects.
##ID##Macro that has the ID value of the object that currently is in memory, in the collection which we are using in.
##CURRID##This macro has the ID value of the currency the Company has associated. The Company has an IDMONEDA, that links with the Gen_Monedas table, with its ID. When entering into the Application, we enter with a Company, which has an associated currency, that is the value shown.
##NOW## Macro that has the system date.
##NULL##Macro that sets a fiel NULL, for that it is used in the ACTION setval.
##FLD_nombrecampo##Macro that will take the value of the field indicated on it.
##VERSION##Version of the app node of the mappings. Value by default 1.0
##DEVICE_MODEL##Model of the device it is being used. Samsung I9000, Iphone 4, IPAD, IPAD2 , etc.
##DEVICE_TYPE##Type of device. Phone, Tablet, Mini, HighPhone…
##FRAME_VERSION##Versión del framework Xone.
##LIVEUPDATE_VERSION##Version of the Liveupdate for the frame that is separated.
##MID##MID of the device in the Platform.
##DEVICEID##IMEI of the device or unique identifier of it.
##DEVICE_MODEL##Model of the device.
##DEVICE_MANUFACTURER##Device Manufacturer.
##DEVICE_OS##Device Operative System.
##DEVICE_OSVERSION##Operative System version.
##DEVICE_OSSDK##SDK level used for the system.
##DEVICE_OSSDKCODE##API code used for the system.
##CURRENT_ORIENTATION##Current orientation of the device.
##SCREEN_RESOLUTION_WIDTH##Width in pixels of the screen.
##SCREEN_RESOLUTION_HEIGHT##Height in pixels of the screen.
##CURRENT_DENSITY##Code. Density. Values (mdpi,ldpi,hdpi,xhdpi,xxhdpi…)
##CURRENT_DENSITY_VALUE##Pixels Density.
##CURRENT_COUNTRY_CODE##Country code according the device language.
##CURRENT_LANGUAGE##Language code according the device language.


It could be done a collection to show the user the information about his device, framework version, live, program, Android version, etc… so that if we ask it knows how to give us this information:

<action name="runscript">
	<script language="VBScript">
		this("MAP_VERSION")=Appdata.globalmacro("##VERSION##")
		this("MAP_FRAMEWORK")=Appdata.globalmacro("##FRAME_VERSION##")
		this("MAP_XONELIVE")=Appdata.globalmacro("##LIVEUPDATE_VERSION##")
		this("MAP_MID")=Appdata.globalmacro("##MID##")
		this("MAP_IMEI")=Appdata.globalmacro("##DEVICEID##")
		this("MAP_MODELO")=Appdata.globalmacro("##DEVICE_MODEL##")
 
		this("MAP_DEVICE_MANUFACTURER")=Appdata.globalmacro("##DEVICE_MANUFACTURER##")
		this("MAP_DEVICE_OS")=Appdata.globalmacro("##DEVICE_OS##")
		this("MAP_DEVICE_OSVERSION")=Appdata.globalmacro("##DEVICE_OSVERSION##")
		this("MAP_DEVICE_OSSDK")=Appdata.globalmacro("##DEVICE_OSSDK##")
		this("MAP_DEVICE_OSSDKCODE")=Appdata.globalmacro("##DEVICE_OSSDKCODE##")
		this("MAP_CURRENT_ORIENTATION")=Appdata.globalmacro("##CURRENT_ORIENTATION##")
		this("MAP_SCREEN_RESOLUTION_WIDTH")=Appdata.globalmacro("##SCREEN_RESOLUTION_WIDTH##")
		this("MAP_SCREEN_RESOLUTION_HEIGHT")=Appdata.globalmacro("##SCREEN_RESOLUTION_HEIGHT##")
		this("MAP_CURRENT_DENSITY")=Appdata.globalmacro("##CURRENT_DENSITY##")
		this("MAP_CURRENT_DENSITY_VALUE")=Appdata.globalmacro("##CURRENT_DENSITY_VALUE##")
		this("MAP_CURRENT_COUNTRY_CODE")=Appdata.globalmacro("##CURRENT_COUNTRY_CODE##")
		this("MAP_CURRENT_LANGUAGE")=Appdata.globalmacro("##CURRENT_LANGUAGE##")
	</script>
</action>


In a collection can be defined MACROS with the name we want, they must start and end with “##”. At the same level that group, frame or the events

    <macro name="##TIPO##" value="1=1" default="true" />

This macro, can then be used in the SQL of the collection, being able to replace the full SQL if necessary.

For instance:

<coll name="Gastos" 
sql="SELECT g.*, g.FECHA as MAP_FECHA 
FROM ##PREF##GASTOS g 
LEFT JOIN ##PREF##TiposGasto tg ON g.IDTIPOGASTO=tg.ID  
WHERE ##TIPO## " filter="g.BAJA=0" objname="Gastos" updateobj="Gastos" progid="ASData.CASBasicDataObj" autorefresh="true" >


Then, somewhere in the code, we can give value to that macro:

<action name="runscript">
	<script language="VBScript">
		collGastos = this.Contents("Gastos")
		collGastos.macro("##TIPO##") = "tg.NOMBRE LIKE '%"+cstr(this("MAP_FTTIPOGASTO"))+"%'"
		....
	</script>
</action>



MACROS MACROS DESCRIPTION
##FLD##Used in the FIELD node of the ASFILTER node. It takes the field value of the collection we have set in the FLDNAME attribute.
##VAL##It replaces the value by what the user has put in the search he wants to perform.
##FFVAL##Macro used for Date comparison. This comparison is made for the values which will be >=, just and only that comparison. This comparison sets the value 00:00:00.
##FTVAL##Macro used for Date comparison. This comparison is made for the the values which will ⇐, just and only that comparison. This comparison sets the value 23:59:00.
##TODAY##Macro that sets today´s date. Used in the filters, when we put a Date field, and we want that automatically set the today´s date. This is made by putting the VALUE attribute to some of the ASFILTER nodes.
##LASTMONTHDAY##This macro sets in the searchings the last day of the month.
##FIRSTMONTHDAY##With this macro we sets the value of the first day of the month.



EJEMPLOS

The first one has one of character type, the second one of numeric type.

<asfilter fontsize="8" left="12">
  <field name="NOMBRE" fldname="NOMBRE" oper="##FLD## LIKE '%##VAL##%'" width="15" tooltip="Nombre" newline="false"></field>
  <field name="PFOOD" fldname="PFOOD" oper="##FLD## &gt;= ##VAL##" width="7" tooltip="DESDE POTENCIAL FOOD" newline="false"></field>
</asfilter>





MACROS MACROS DESCRIPTION
Appdata.FailWithMessage -11888,"Mensaje" Informative message with the fail found. It throws an exception in the framework that can be captured with ppData.error.number, appData.error.description… If it is in an insert node for instance, it causes that it does not take place. The numbers -11888, -8100, etc, in Windows Mobile did show different icons (warning, cancel, etc), the most modern frameworks no longer show icons and all the numbers are treated the same.
Appdata.FailWithMessage -8100,"Mensaje"Same than the previous one.
Appdata.FailWithMessage -11811,"Mensaje"Framework message, same than the 11888.
Appdata.FailWithMessage -11822,"Mensaje"Message with possibility of blocking with button.
Appdata.FailWithMessage -666,"Mensaje"Refreshing the header when it is executed with the Selecteditem. IT IS NO LONGER NECESSARY.
Appdata.FailWithMessage -11888,"##EXIT##" Used to exit the Edit windows.
Appdata.FailWithMessage -11888,"##EXITAPP##"To indicate to go out from the application.
Appdata.FailWithMessage -11888,"##RESETAPP##"Reseting the application.
Appdata.FailWithMessage -11888,"##STARTREPLICA##"Starting the replica from an script.
Appdata.FailWithMessage -11888,"##STARTREPLICA####EXIT##"Two macros at the same time can be put, in such way that they are executed in the order in which they were put. In this case, it starts the replica and closes the edition window.
Appdata.FailWithMessage -11888,"##SOUND##"To enable a sound at the PDA. In PDA must have an /icons/aviso.wav and in BB(5+)has to be in /xone/nombreapp/sounds/button-13.mp3.
Appdata.FailWithMessage -11888,"##LOGIN_START##"It indicates to the customized login screen to continue with the application.
Appdata.FailWithMessage-11888,"##WIFION##"Turn on WIFI
Appdata.FailWithMessage -11888,"##WIFIOFF##"Turn off WIFI
Appdata.FailWithMessage -11888,"##STOPREPLICA##"It stops the replica process.
Appdata.FailWithMessage -11888,"##FORCECONNECTION1##"It stops the replica and forces as HOST address the specified one in HostName of the license.ini file.
Appdata.FailWithMessage -11888,"##FORCECONNECTION2##"It stops the replica, and forces as Host address, the specified one in HostName2 of thelicense.ini file.
Appdata.FailWithMessage -11888,"##DISABLECONNECTION1##"It stops the replica, and disables the host address, specified in HostName of the license.ini file.
Appdata.FailWithMessage -11888,"##DISABLECONNECTION2##"It stops the replica, and disables the host address, specified in HostName2 of the license.ini file.
Appdata.FailWithMessage -11888,"##DISABLEALLCONNECTION##"It stops the replica, and disables the two host address specified in HostName and HostName2 of the license.ini file.
Appdata.FailWithMessage -11888,"##ENABLECONNECTION1##"It enables the host address, specified in HostName of the license.ini file.
Appdata.FailWithMessage -11888,"##ENABLECONNECTION2##"It enables the host address, specified in HostName2 of the license.ini file.
Appdata.FailWithMessage -11888,"##ENABLEALLCONNECTION##"It enables the two host address specified in HostName and HostName2 of the license.ini file.
Appdata.FailWithMessage -11888,"##PANEL_REFRESH##"It refreshs the content of the floating panels (special edition windows), of the main menu window.




MACROSMACROS DESCRIPTION
Appdata.FailWithMessage -11888,"##WIFIOFFAFTERREPLICATE##“At the end of the replication cycle, WIFI is turned off.
Appdata.FailWithMessage -11888,"##STARTREPLICABLOCKING##“If it is not replicating it starts the replica cycle, and if is in the edition window, it blocks that window.
Appdata.FailWithMessage -11888,"##DISCONNECT##“It stops the replica and closes its active network connection .
Appdata.FailWithMessage -11888,"##STARTREPLICAANDEXIT##“It starts the replica and exit from the application when the cycle is completed properly.