Variable Reference

Variable Reference

The following variables can be placed in the HTML of any custom item. MediaLab will substitute the appropriate values in the HTML code before it is displayed. This is a convenient way to substitute information from the current MediaLab item without having to alter the HTML code. Such substitutions could include color and font information, response options, question wording, background images, parameters, and so forth.

Note that you can also substitute calculated values from a responses.xls file by placing the variable name in angular brackets. For example, if you had a calculated value named "total" in your responses.xls file, you could enter <total> in your HTML file and MediaLab would substitute the correct value at the time the HTML is displayed.
 

<ml.subject>

Subject ID

<ml.$>

quickstyle

<ml.condition>

Condition

<ml.@>

time stamp

<ml.varname>

Variable Name

<ml.c>

command line arguments

<ml.wording>

Question Wording. Will also include substitutions from responses.xls if applicable.

<ml.d>

duration - not available as a variable

<ml.color>

Main area text color. Will have prefix "#" e.g., #CCCCFF

<ml.h>

height

<ml.bgcolor>

Main area background color. Will have prefix "#" e.g., #CCCCFF

<ml.k>

key

<ml.font>

Main area font name, e.g., arial

<ml.l>

left position

<ml.fontsize>

Main area font size. Will have "pt" appended, e.g., 16pt.

<ml.m>

mask

<ml.color2>

Input area text color. Will have prefix "#" e.g., #CCCCFF

<ml.n>

number of thoughts to take

<ml.bgcolor2>

Input area background color. Will have prefix "#" e.g., #CCCCFF

<ml.o>

question wording onset

<ml.font2>

Input area font name, e.g., arial

<ml.p>

number of scale points (1-12)

<ml.fontsize>

Input area font size. Will have "pt" appended, e.g., 16pt.

<ml.q>

target question for thought rating

<ml.bg>

BackGround. Append parameters if desired: .t, .l, .h, .w, e.g., <ml.bg.w>

<ml.r>

range

<ml.bs>

BackSound

<ml.s>

spacing

<ml.bv>

BackVideo. Append parameters if desired: .t, .l, .h, .w, e.g., <ml.bg.w>

<ml.t>

top position

<ml.textx>

Text Label (1-12). Replace x with option number, e.g., <ml.text7>

<ml.ttl>

send ttl signal

<ml.labelx>

Button Label (1-12). Replace x with option number, e.g., <ml.label7>

<ml.w>

width

<ml.skiptox>

SkipTo Value (1-12). Replace x with option number, e.g., <ml.skipto10>

<ml.x>

password required to continue

<ml.goback>

Whether GoBack is allowed. True/False.



<...>

Any variable from responses.xls. Specify variable in angular brackets, e.g., <var1>.



 

All of the variables above may be directly substituted into your HTML file. For example, if the question wording in you HTML were: "Please choose from one of the <ml.p> alternatives" and you had used the parameter (p5), the question wording would appear as "Please choose from one of the 5 alternatives."

The code to display an image in HTML may look like this:

<img src="mypic.jpg">

Instead of having this be a fixed image, you could have your custom item pull up a different picture every time by placing an image in the background field in the questionnaire. Then, in your HTML you could specify:

<img src="<ml.bg>">

Voila--a different picture every time--whatever you have put in the BackGround field!

Indirect Substitution (optional)

Values may be directly substituted by entering them directly into the HTML code as above. This can make previewing the HTML (e.e., in Internet Explorer) a little difficult because IE won't know what <ml.bg> means. If you don't care about previewing the HTML, then it doesn't really matter. However, there is an alternative method called indirect substitution where you can list the substitutions below all the HTML code like this:

<form method="post">
  <img src="mypic.jpg"><br>
    some wording here
   <input name="varname">
   <input type="submit" value="Continue"">
</form>

<!--ml.subs
ml.sub "question wording" = <ml.wording>
ml.sub "varname" = <ml.varname>
ml.sub "mypic.jpg" = <ml.bg>
-->

See Also
Custom Items, Overview
Repeating Custom Items
Single Vs. Multiple Variables
Samples