User Tools

Site Tools


en:wiki:2.-desarrollo-app:2.6.-demos-y-ejemplos:a.-ejemplos-codigo-vbscript:start



Examples of VBScript codes


VBScript Programming Templates


Code that browses a full collection


<action name="runscript">
	<script language="VBScript">
		Dim coll, filtro	
		‘Variable con la coleccion que se va a utilizar					
		Set coll =AppData.GetCollection("PresupuestosScript")
		‘Guardamos el filtro que tiene la coleccion por defecto 
		filtro=coll.filter
		‘Le ponemos un filtro con el atributo filter, 
		‘que machacaría el filtro que ya tiene la coll en su atributo filter.
		coll.filter="MAP_SIMBTIPO='PR'"
		‘Función para ejecutar el SQL de la coll, y poder recorrer los record que tiene dicha coll		
		coll.StartBrowse
			‘Utilizamos un while, preguntando si el registro actual es nulo o no.
			while not coll.CurrentItem is nothing 									
				if coll.CurrentItem("OPTIONS") = 0 then
					coll.currentItem("OPTIONS")=1
					coll.currentItem.Save									
				end if
				‘Para pasar al siguiente registro de la coll
				coll.MoveNext						
			wend
		‘Siempre que se hace un StartBrowse, tiene que existir un EndBrowse, que es para cerrar la conexión.
		coll.EndBrowse
		‘Restauramos el filtro original
 		coll.filter=filtro
		Set coll=nothing
	</script>
</action>


coll.filter, adds an AND to the filter that the collection has currently applied in the filter attribute of the XML at the SQL of the collection, or to the filter defined by calling the contents, coll.linkfilter would be to change this one, also. (CAREFUL! when changing the filter of a collection, remember to restore it afterwards…)

Browsing a collection/contents with few data


	<action name="runscript">
		<script language="VBScript">
			Dim colldet,j,i,valor
			‘Cogemos la coll contents Detalles del objeto actual This.
			Set colldet=this.contents("Detalles")
		 	j=0
			‘Guardamos en la variable i el número de registros que tiene el content.
			i=this.contents("Detalles").count
 
			‘Si es cero se pueden dar dos opciones:
		        ‘ - Que no haya ningún registro
              		‘ - Que aún no se haya cargado el content y por eso no tengamos ningún registro
		        ‘Así que le hacemos un loadall para cargarlos todos (si no están cargados), y si no hubiera
		        ‘registros no pasaría nada al hacer el loadall.
 
			‘El loadall cuidado con su uso, ya que si tiene muchos elementos, nos quedaremos sin memoria. 
			‘El máximo número de registros de una colección para cargarla con loadall podemos fijarla en 20 
			‘claro está, todo depende de lo grande que sea cada registro de dicha colección.
		  	if i=0 then
		  		this.contents("Detalles").loadall
				i=this.contents("Detalles").count
		   	end if
			‘Utilizamos un For para recorrer los registros del contents.
		   	For j=0 to i-1
				‘Tomamos el valor del content con el indice de dicho registro.
		  		valor=colldet(j)("IDARTICULO")
		   		if valor="loquesea" then
			   		‘ Realizar la función deseada
		   		end if
		   	next
			‘Liberamos memoria.
			Set colldet=nothing
		</script>
	</action>


Getting an object (row) from a collection, having the value of a field from such object


	Dim obj
	‘Buscamos el cliente en la coll Clientes, con el valor del ID del cliente.
	Set obj=appdata.getcollection("Clientes")("ID",CStr(This("IDCLIENTE")))
	If not obj is nothing Then
		obj("PROXIMA")=This("PROXIMA")
		obj("OBSERVACIONES")=This("FICHA")
		obj.save
	End If
	Set obj=nothing


Getting an object (row) from a collection, by using an SQL with more than 1 field (FINDOBJECT)


AppData.PushValue objLoquesea lanza un objeto en edición.

Set cCierre=AppData.GetCollection("Cierre")
Set objCierre=cCierre.FindObject("NUMINCIDENCIA='"+This("NUMINCIDENCIA")+"' AND NUMPROGRESO='"+This("NUMPROGRESO")+"'")
If  objCierre Is Nothing Then	
	set objCierre=cCierre.CreateObject
	objCierre("MAP_IDINCIDENCIA")=This("ID")
	objCierre("NUMINCIDENCIA")=This("NUMINCIDENCIA")
	objCierre("NUMPROGRESO")=This("NUMPROGRESO")
	ContarPiezas This("NUMINCIDENCIA"),This("NUMPROGRESO")
	objCierre("MAP_NUMPIEZAS")=This("MAP_NUMPIEZAS")
	cCierre.additem objCierre
	AppData.PushValue objCierre
Else
	Appdata.failwithmessage -11888,"Ya ha ejecutado el cierre con anterioridad."
End If


Messages (msgBox showToast) Notifications Sounds


We have several ways to show a message on screen.

Command Description
ui.MsgBox “Ejemplo”, “Mensaje”, 0 “regular” message of the framework, to vanish, the user must click into the OK button.
ui.ShowNotification 1, “Título”, “Mensaje” Notification at the notifications top bar, an ID (1) will be specified in order if we want to modify the notification further on, we can use the same command with another message and the one that already did exist will be modified.
ui.DismissNotification “1” It deletes the Notification from the notifications top bar made with the “ShowNotification”, we have to specify the ID (1) of the notification to specify the message we want to remove. The parameter is necessary to pass it like a string.
ui.ShowToast “A new message has been received ” TOAST message from the operative system, see screenshot below. The message automatically vanishes after a couple of seconds on screen.


Example of code:

<mensajes show-wait-dialog="false">
	<action name="runscript">
	<script language="VBScript">
      		'MsgBox0,MsgBox1,MsgBox4,ShowToast,ShowNotification,Sonido
      		Dim vResult
 
		Select Case this("MAP_TIPO_MENSAJE")
			Case "MsgBox0"
				ui.msgBox "Mensaje Informativo solo con OK","Titulo Ventana",0
			Case "MsgBox1"
				'Si pulsa ACEPTAR, vResult vale 1 y si pulsa CANCELAR vale 2
				vResult =ui.MsgBox ("Pregunta si ACEPTAR ó CANCELAR","Advertencia",1)
				ui.msgBox "Ha pulsado el botón con valor: "+cstr(vResult),"Titulo Ventana",0
			Case "MsgBox4"
				'Si pulsa SI, vResult vale 6 y si pulsa NO vale 7
				vResult =ui.MsgBox ("Pregunta SI ó NO","Advertencia",4)
				ui.msgBox "Ha pulsado el botón con valor: "+cstr(vResult),"Titulo Ventana",0
			Case "ShowToast"
				ui.showToast "Mensajito efímero que dura 3 segundos"
			Case "ShowNotification"
				ui.ShowNotification 1, "Título", "Esto es una notificación", "Aviso de recepción de datos"
			Case "Sonido"
				'El sonido tiene que estar en la carpeta files del proyecto
				ui.playSoundAndVibrate "beep-6.wav",true,1
			End Select
 
		</script>
	</action>
</mensajes>


Node to go to a collection by passing a parameter (irColl)


First, we should have a button to call this node:


  	<prop name="BTOPCION1" type="B" width="260p" height="320p" img="option_gastos.png" method="ExecuteNode(irColl(Socios))" />


The node code would be:

	'Hemos llamado al nodo irColl pero podríamos haberlo llamado de cualquier otra forma.
	<irColl show-wait-dialog="false">
		<action name="runscript">
		<param name="parametro" />
			<script language="VBScript">
		                'Para abrir una colección "nombre_coll", mascara, modo(0-listado, 1-edicion)
                		appData.userInterface.openMenu parametro,127,0
 
				'O bien podemos crear un objeto nuevo en la colección llamada y lanzarlo en edición.
				set coll=appData.getCollection(parametro)
				set det = coll.createObject
				coll.addItem Empty,det 
				appData.pushValue det 
			</script>
		</action>
	</irColl>


Node to exit from a collection (onback)


We call it onback because in Android we have an event that attends the come back button that executes this node, in such a way that the button we put to exit and the Android come back button do the same.

We should have an exit button or a back button to execute this node.

	<prop name="BTSALIR" type="B" img="logout.png" width="128p" height="128p" method="ExecuteNode(onback)" />


This is the code that executes as our button as the Android come back button.

	<onback>
		<action name="runscript">
			<script language="VBScript">
	  			AppData.FailWithMessage -11888,"##EXIT##"
			</script>
		</action>
	</onback>


Node to move to another tab (showGroup)


In this code, we also see how we can change dynamicaly a property, in this case, the background image of a frame.

	<frame name="cabecera1" width="100%" height="95px" align="left|center" imgbk="##FLD_MAP_FONDOCABECERA##">
		-----
	</frame>
	<prop name="MAP_FONDOCABECERA" type="T" visible="0" />
	<prop name="MAP_IR_FOTO" type="B" img="./icons/boton_foto.png" method="ExecuteNode (goGroup(2))" width="163px" height="60px" />


	<goGroup show-wait-dialog="false">
		<action name="runscript">
		  <param name="grupo" />
		  <script language="VBScript">
				select case cstr(grupo)
				case "1"
					this("MAP_FONDOCABECERA")="./icons/cabecera_rojo.jpg"
				case "2"
					this("MAP_FONDOCABECERA")="./icons/cabecera_verde.jpg"
				case "3"
					this("MAP_FONDOCABECERA")="./icons/cabecera_azul.jpg"
				end select
 
				'Con este método le decimos que nos muestre otra pestaña	  			
				ui.ShowGroup cstr(grupo),"##RIGHT##",500,"##RIGHT_OUT##",500
			</script>
		</action>
	</goGroup>


CASE in SQL for COLORVIEW


For those who need to consult about SQL…

SELECT g.*,CASE WHEN g.APROBADO=0 THEN '#FFFFFF' ELSE '#00FF00' END AS MAP_COLORVIEW FROM ##PREF##Gastos g


MACRO of an user to filter contents


We can create an user MACRO in a collection to replace on real time the SQL of a collection, being able to replace even the SQL of the full collection.

<coll name="Gastos" 
sql="SELECT g.*, g.FECHA as MAP_FECHA, tg.NOMBRE as MAP_GASTO, g.IMPORTE as MAP_IMPORTE,  
g.PROVEEDOR as MAP_PROVEEDOR, tg.NOMBRE as MAP_GASTO2, g.FOTO1 as MAP_FOTO1, 
g.FOTO2 as MAP_FOTO2, g.FOTO3 as MAP_FOTO3,  
FROM ##PREF##GASTOS g LEFT JOIN ##PREF##TiposGasto tg ON g.IDTIPOGASTO=tg.ID  
WHERE ##TIPO## " filter="g.BAJA=0" objname="Gastos" updateobj="Gastos" ... />
 
<macro name="##TIPO##" value="1=1" default="true" />


Once defined the macro at the collection, we can use it later to change the value of such macro and therefore changing the SQL.

<onchange>
	<field name="MAP_FTTIPOGASTO">
		<action name="runscript">
			<script language="VBScript">
				collGastos = this.Contents("Gastos")
 
				'Aquí cambiamos el valor de la macro que tenemos definida en la colección Gastos.
				collGastos.macro("##TIPO##") = "tg.NOMBRE LIKE '%"+cstr(this("MAP_FTTIPOGASTO"))+"%'"
 
				this.ExecuteNode "refrescaTotal"
			</script>
		</action>
	</field>
</onchange>


Code to Create/Edit/Delete a record from a contents


'Para poder dar de alta un registro en un contents tendríamos que pasarle el ID de la cabecera...
function addContents(coll,campoenlace)
	Set CollCV=appdata.GetCollection(coll)
	Set ObjCV=CollCV.CreateObject
	ObjCV(campoenlace) = this("ID")
	CollCV.AddItem Empty,ObjCV
	AppData.PushValue ObjCV 	
end function 
 
'A esta función tenemos que pasarle la referencia al contents y el ID que queremos editar. 
function editContents(coll,idselected)
	Set CollCV=appdata.GetCollection(coll)
	Set ObjCV=CollCV.FindObject("ID="+Cstr(idselected))
	if not ObjCV is nothing then
		AppData.PushValue ObjCV 
	end if	
end function
 
'Realmente no borramos el registro físicamente, lo que hacemos es cambiar el campo de enlace con la cabecera
'o podemos ponerle un BAJA=1, para darlo de baja lógica. Posteriormente tendríamos un mantenimiento para
'eliminar estos registros del dispositivo (Para que no se replique el borrado físico del registro).
function deleteContents(coll,idselected,campoenlace)
	result = ui.MsgBox("¿Esta seguro de que desea eliminar el registro seleccionado?","¡ALERTA!",4)
	if result=6 then
		Set CollCV=appdata.GetCollection(coll)
		Set ObjCV=CollCV.FindObject("ID="+Cstr(idselected))
		if not ObjCV is nothing then
			ObjCV(campoenlace) = -9999
			ObjCV.Save
		end if	
		ObjCV = nothing	
		CollCV = nothing	
	end if
end function


Displaying error by screen


<script language="VBScript">
    if this("IDCLIENTE")= 0 then
	Appdata.FailWithMessage -8100,"¡¡No ha seleccionado un cliente.!!"
    end if							
    'SCRIPT PARA REALIZAR LA VALIDACION DE LOS DETALLES, QUE SE MIRA SI EL CAMPO IDTARIFA 
    'ESTA LLENO O NO. SI DA ERROR, MUESTRA UN MENSAJE DE TIPO -8100, PARA DECIR QUE ES ERROR.
    Dim i,j
 
    Dim colldet
    Set colldet=this.contents("DetallesCabecera")
    j=0
    i=this.contents("DetallesCabecera").count
    if i=0 then
        this.contents("DetallesCabecera").loadall
    end if
    i=this.contents("DetallesCabecera").count
    while i &lt;&gt; 0 
        valor=colldet(j)("IDTARIFA")
            if valor=0 then
                i=0
                aux=1   
            else
                i=i-1
                j=j+1
            end if
        if aux=1 then Appdata.FailWithMessage -8100,"¡¡Hay Detalles sin Tarifa!!" 
    wend							
</script>


Types of errors


<script language="VBScript">
    'ERROR DISPONIBLE EN TODAS LAS PLATAFORMAS
        'Muestra un mensaje de error con el texto que le pongamos
        appdata.failwithmessage -8100,"Mensaje de error"
 
    'ERRORES DISPONIBLES EN PLATAFORMA POCKET PC
        'Muestra un mensaje de error con el texto que le pongamos
        appdata.failwithmessage -7500,"Mensaje de warning"
 
        'Refresca la cabecera cuando se ejecuta con el Selecteditem. YA NO ES NECESARIO.
        appdata.failwithmessage -666,"Mensaje de información"
 
        'Mensaje de informacion con icono de Información
        appdata.failwithmessage -11888,"Mensaje que queremos mostrar"
 
        'Mensaje personalizado con posiblidad de bloqueo con botón.
        appdata.failwithmessage -11822,"Mensaje de información"
 
        'Mensaje propio de CGS
        appdata.failwithmessage -11811,"Mensaje de información"
 
        'Inicia la replica desde un script
        Appdata.FailWithMessage -8100,"##STARTREPLICA##"
 
        'Esta macro funciona conjuntamente con CGStart (kiosko de PDA). 
        'Cierra el frame y le dice al kiosko q reinicie la PDA. 
        'Si el kiosko no está instalado, simplemente se cierra la aplicación.
        Appdata.FailWithMessage -8100,"##RESETAPP##"
 
        'Salir de la aplicacion.
        Appdata.FailWithMessage -8100,"##EXITAPP##"
 
        'Usado para salir de las ventanas de Nomen y Edit.
        Appdata.FailWithMessage -8100,"##EXIT##"
</script>


Data validation by using PopValue and PushValue for the errors


To avoid saving a record with fields with certain values, as empty ones.

Appdata.PopValue is to take the value of the rule fail, to give it later with Appdata.PushValue.

It will be passed as a Long, from there the Clng.


<insert>
    <rule name="fail-if-not-valid">
        <rule name="runscript" msg="Faltan por rellenar campos obligatorios.">
            <script language="VBScript">
                Dim	bFail,x							
                x =AppData.PopValue
                bFail =0
                if This("FECHANAC") &lt;&gt; "" then
                    if This("DNI")&lt;&gt;"" AND bFail=0 then
                        bFail=0
        	    else
	    	        bFail=1
		    end if
		    if This("PROVINCIA")&lt;&gt;"" AND bFail=0 then
		        bFail=0
		    else
		        bFail=1
		    end if
		    if This("CALLE")&lt;&gt;"" AND bFail=0 then
		        bFail=0
		    else
		        bFail=1
		    end if
		    if This("IDPROPIETARIO")&lt;&gt;"" AND bFail=0 then
		        bFail=0
		    else
		        bFail=1
		    end if						
		    if bfail=0 then 
		        This("%FALTANDATOS")=0
		    else 	
		        This("%FALTANDATOS")=1
		    end if	
		Else
		    This("%FALTANDATOS")=1								
		end if													
		AppData.PushValue (CLng(bFail))
            </script>
        </rule>
    </rule>
</insert>


Button with Script


CODE TO MAKE A BUTTON.

It is composed of 3 nodes:

Node 1Prop of the type “B” (button) It is the node that defines the place where it comes, title and to which node calls to execute its code. It has the method attribute that is the one that makes the call to the node that has its code, the name “ExecuteNode”, is the name of the “method” node, and has to be called similarly (uppercase-lowercase).
Node 2Node method name=“ExecuteNode“ It is a mandatory and fixed node. (IT IS NOT NECESSARY ALREADY, only in old framesorks.)
Node 3Node in which the code that will be executed is put. The name is defined by the user, and as only requirement, is the node name, it has to be called equal (uppercase-lowercase) than the node to which the button node calls in its method attribute.


<prop name="Iniciar" group="3" type="B" method="ExecuteNode (inicializar)" title="Iniciar Ruta" visible="1" toolbar="false" labelwidth="24"  onchange="refresh255" lmargin="7"/>
 
<method name="ExecuteNode">
	<param name="P1" type="T" value=""/>
</method>
 
<inicializar>
	<action name="runscript">
		<script language="VBScript">
			Dim vResult
			vResult =AppData.UserInterface.MsgBox ("Esta acción reiniciará toda la ruta. ¿Está seguro que desea ejecutarla?","Advertencia",1)
			If vResult =1 Then 				
				appdata.executeSQL "UPDATE Gen_Rutas SET VISITADO=0 WHERE IDUSUARIO=" + CStr(This("IDUSUARIO"))
				vResult =AppData.UserInterface.MsgBox ("Ruta inicializada","Advertencia",0)
			End If							
		</script>
	</action>
</inicializar>


Notices Collection


NOTICES COLLECTION.

<coll name="Avisos" title="el aviso" sql="SELECT d.ID
	FROM (##PREF##Documentos d
	LEFT OUTER JOIN ##PREF##TiposDocumento td ON d.IDTIPODOC=td.ID)
	WHERE td.SIMBOLO='PD' AND d.OP1=1" objname="Documentos" updateobj="Documentos" progid="ASData.CASBasicDataObj" 
	 notify="true" notify_counter="false" notify_coll="ParteDiario" alternate-counter="true" notify_title="Entregas Avisos">
	<group name="General" id="1"></group>
	<prop name="ID" group="1" visible="7" type="N" fieldsize="5"></prop>
</coll>


Content Image


CONTENT IN IMAGE MODE.


With this content the data will be displayed as a image, and the user, in some coordinates of it, will be entitled to put marks.
By making a click in this mark it will display the data relative to it, it would be as giving to a line from a regular content.

We need to keep in mind that the example is to display in a first image a vehicle, and if it is given to one place of it, which will be able to be a tyre, a glass or a door, they wil come up several types of damages that such part of the vehicle can have.


TWO CONTENTS IN A HEADING COLL. The first one is the image-type content, that has the attributes:


viewmode TO INDICATE THAT THE CONTENT HAS TO BE DISPLAYED IN IMAGE MODE.
imgbk IT IS SAID THE IMAGE TO BE DISPLAYED.


The other content is the one which is put underneath and according the place where the image content is marked, they will come up the relative data.


	<prop name="MAP_KK31-" title="Tarea Verificar. Daños" labelwidth="23" bgcolor="#CC3333" group="3" visible="0" fieldsize="8" size="8" type="TL" labelshadow="false" forecolor="#FFFFFF"/>
	<prop name="@PLANTILLA1" group="3" visible="1" type="Z" contents="Plantilla1" viewmode="picturemap" imgbk="##FLD_MAP_IMGPLANTILLA1##" bgcolor="#FFFFFF" lines="7" onchange="Refresh" mask="2" height="40%"/>
	<contents name="Plantilla1" src="Plantilla1" group="3" filter="t1.IDDOCPLANTILLA=##FLD_MAP_IDPLANTILLA1##" macros="##MACRO1##(##FLD_TAREAID##)" mask="2" bgcolor="#FFFFFF"></contents>
	<button name="AntesVeh" group="3" caption="&lt;&lt;                  &gt;&gt;" visible="true" labelwidth="12" lmargin="9" onchange="Refresh" method="ExecuteNode (antesveh)" labelfont-bold="true" bgcolor="#FFFFFF" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="MAP_PLANTILLA" title="Vista:" labelwidth="0" type="T" size="150" locked="true" locking="true" newline="false" lmargin="1" showinline="true" linkedto="MAP_IDPLANTILLA1" linkedfield="DESCRIPCION" fieldsize="14" visible="0" group="3" onchange="Refresh255" labelshadow="false" forecolor="#CC3333" bgcolor="#FFFFFF" text-border-top="false" text-border-bottom="false" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<button name="DespuesVeh" group="3" caption="&gt;&gt;" visible="false" labelwidth="4" newline="false" lmargin="1" onchange="Refresh" method="ExecuteNode (despuesveh)" labelfont-bold="true" bgcolor="#FFFFFF" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="@PDANOS1" group="3" visible="1" type="Z" contents="Danos1" lines="7" onchange="Refresh" mask="2" height="45%"/>
	<contents name="Danos1" src="Danos1" group="3" filter="t1.SITUACION=##FLD_MAP_SITUACION##" macros="##MACRO1##(##FLD_TAREAID##)" mask="2"></contents>
 
 
	<!-- COLL QUE ES EL CONTENT DE IMAGEN. TIENE QUE TENER 4 CAMPOS QUE TENDRAN LOS ATRIBUTOS PARA PINTAR LA MARCA EN EL DIBUJO QUE SE MUESTRA
		xcoord="true": COORDENADA X
		ycoord="true": COORDENADA Y
		circle-radius="true": PARA INDICAR EL RADIO DEL CIRCULO DE LA MARCA
		icon-mark="true": ICONO DE LA MARCA A PONER
	-->
<coll name="Plantilla1" title="Plantilla1"
	sql="SELECT t1.ID,t1.XCOORD,t1.YCOORD,
	t1.RADIO,t1.SITUACION,t1.ROWID AS MAP_ROWID,
	t2.ID AS MAP_IDMPLANTILLA,t2.CONTADOR AS MAP_CONTADOR,
	CASE 
	WHEN t2.CONTADOR&gt;0 THEN t1.ICONMARK 
	ELSE '' 
	END AS ICONMARK
	FROM ##PREF##detplantilla t1
	LEFT OUTER JOIN ##PREF##marcaplantilla t2 ON t1.ID=t2.IDDETPLANTILLA AND t2.TAREAID=##MACRO1##"
	objname="detplantilla" updateobj="detplantilla" progid="ASData.CasBasicDataObj" fontsize="8" editmask="2">
	<!-- PESTAÑAS -->
	<group name="Puntos" id="1"></group>
	<!-- CAMPOS VISIBLES -->
	<macro name="##MACRO1##" value="0" default="true"/>
	<!--  -->
	<prop name="XCOORD" title="X COORD" xcoord="true" labelwidth="6" type="N" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="YCOORD" title="Y COORD" ycoord="true" labelwidth="6" type="N" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="RADIO" title="RADIO" circle-radius="true" labelwidth="6" type="N" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="SITUACION" title="SITUACION" labelwidth="6" type="N" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="ICONMARK" title="" icon-mark="true" labelwidth="6" type="T" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="MAP_IDMPLANTILLA" labelwidth="6" type="N" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="MAP_CONTADOR" labelwidth="6" type="N" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
	<prop name="MAP_ROWID" labelwidth="6" type="T" size="15" locked="true" locking="true" fieldsize="8" visible="7" group="1" labelshadow="false" forecolor="#CC3333" bgcolor="#CC3333" text-border-top="false" text-border-bottom="true" text-border-left="false" text-border-right="false" labelfont-bold="true" labelbox="false" labelfontsize="10" textfontsize="10" fontsize="10" text-bgcolor-disabled="#FFFFFF"/>
 
	<selecteditem onchange="Refresh255">
		<action name="runscript">
			<script language="VBScript">
				'DATOS DE LA PRIMERA PESTANHA
				this.ownerCollection.ownerObject("MAP_SITUACION")=This("SITUACION")
				this.ownerCollection.ownerObject("MAP_IDDETP1")=This("ID")
				this.ownerCollection.ownerObject("MAP_IDMP1")=This("MAP_IDMPLANTILLA")
				this.ownerCollection.ownerObject("MAP_CONP1")=This("MAP_CONTADOR")
				this.ownerCollection.ownerObject("MAP_DETIDP1")=This("MAP_ROWID")
				//appdata.failwithmessage -666,"" YA NO ES NECESARIO!!!
			</script>
		</action>
	</selecteditem>
</coll>


Creating a Record with Script


CREATING A NEW RECORD WITH A SCRIPT.

The script will be able to be executed in a create, insert, delete, botón… at any place.

<action name="histor" type="runscript">					
	<script language="VBScript">
		'Dimensionamos las variables
		Dim coll,det					
		'Cogemos en que coleccion se va a crear el nuevo objeto, con lo que tomara todas las caracteristicas del mismo, 
		' ejecutandose el create si lo tuviera.
		Set coll =AppData.GetCollection("ColeccionEnLaQueSeCreaElRegistro")
		'Creamos el objeto
		set det = coll.CreateObject
		'Lo añadimos a la coll, lanzando el create del mismo
		coll.AddItem Empty,det
		'Añado los valores a los distintos campos
		det("CAMPONUMERICO")=5
		det("CAMPOTEXTO")="VALOR DEL CAMPO"
		det("CAMPOFECHA")=now()
		'Salvo el objeto
		det.Save				
		'Liberamos variables.
		set coll.clear
		Set coll=nothing
		Set det=nothing								
	</script>
</action>


Giving value to a Global Variable


<action name="runscript">
	<script language="VBScript">
		appdata.CurrentEnterprise.Variables("NoAvisar")=0
	</script>
</action>


Queue Device Information


COLLECTION THAT DISPLAYS THE AMOUNT OF DATA THAT REMAIN TO BE SENT.

This collection can be more difficult if we want to, even by putting Join with another tables, to tell from which table remains the data to be sent from the mobile device to the central.

The MASTER_REPLICA_QUEUE table, only can be used to see the data, never for writting on it directly, since it is a system table, with which the data will be sent from the mobile device to the central server.

<coll name="InformacionQueue" title="la informacion queue" 
	sql="SELECT COUNT(ID) AS MAP_CUENTA
	FROM master_replica_queue"
	objname="master_replica_queue" updateobj="master_replica_queue" progid="ASData.CASBasicDataObj" forprint="false" 
	editwidth="75" editheight="76" autorefresh="true">
	<group name="General" id="1"/>
	<prop name="MAP_CUENTA" visible="7" group="1" type="N" fieldsize="20" labelwidth="8" size="30">DATOS PARA ENVIAR</prop>
</coll>	


en/wiki/2.-desarrollo-app/2.6.-demos-y-ejemplos/a.-ejemplos-codigo-vbscript/start.txt · Last modified: 2018/04/20 13:39 (external edit)