From wiki.ginstr.com
Jump to: navigation, search
 
Line 29: Line 29:
 
**<code>[[Datatypes#text|text]]</code>
 
**<code>[[Datatypes#text|text]]</code>
  
* Valid formatting targets:
+
* Valid formats:
 
** <code>default</code> keyword. If set the format will be reset to internal default format.
 
** <code>default</code> keyword. If set the format will be reset to internal default format.
 
:* for <code>[[Datatypes#email|email]]</code> use formatting [https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html rules]
 
:* for <code>[[Datatypes#email|email]]</code> use formatting [https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html rules]

Latest revision as of 11:16, 7 May 2018

gn:act_setFormat

Description
Action used to set format to a target when the target is printed out as string.
i.e. gn:act_sendEmail converts values to string values before sending them via email. If we would like to send gps location in some url and not as raw value then we would format the target which holds gps before using email action.
Action returns
void

Action signatures

[gn:act_setFormat]|[target, format]
Parameter Description
target target target to which format will be set.
format format Format which will be set on target. Format needs to be stored into a text datatype or a string resource.
  • Valid formats:
    • default keyword. If set the format will be reset to internal default format.
default format: %1$s : %2$s (name,email)
default format: %1$s:%2$s (latitude,longitude)
default format: 0.00
default format: %1$s : %2$s : %3$s (name,info,phonenumber)
default format: %1$s : %2$s : %3$s (IBAN,BIC,bank)

Example

initial format
@variable/medicalAlert_phone_serialNumber = 0.00
initial value outputed as string
273743762924508.00
variables.xml
<variable id="medicalAlert_phone_serialNumber" type="number" defaultValue=""></variable>
strings.xml
<string name="formatNumber">#</string>
screen.xml
<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_set="[gn:act_setFormat]|[@variable/medicalAlert_phone_serialNumber,@string/formatNumber];" />
after action execution format
@variable/medicalAlert_phone_serialNumber = #
after action execution value outputed as string
273743762924508