PDA

View Full Version : Newbe question: Problem with variable in value


mulion21
02-28-2005, 12:40 PM
Hi,

I am tring to get a variable in a value tag but I always get the "${'myApp.language'}" string instead of the value "@english". Can you tell me what I do wrong?

Sample code:

<dataset name="dset" src="label.xml"/>
<attribute name="language" value="@english" type="string"/>
<attribute name="languagepath" value="dset:/label/myButton/${'myApp.language'}" type="string"/>

<script>
Debug.Write(myApp.language);
Debug.Write(myApp.languagepath);
</script>

rajkaushik
02-28-2005, 12:45 PM
can you post your (a part of) dataset.
Raj

mulion21
03-01-2005, 05:04 AM
<label>

<myButton
english="this is english"
french="ceci est francais"
/>

<myWindowTitle
english="this is english"
french="ceci est francais"
/>
</label>

sourada
03-01-2005, 06:58 AM
I think the problem is the quotes around the variable name. Try just ${myApp.language}. Actually, I think I'd try just ${language}.

mulion21
03-01-2005, 09:18 AM
It is not working.

I am only tring to passe an attribute as a variable to the other attribute:

Here is the complete code, if you look a the debug windows you will see that the value displayed for languagepath is: "dset:/label/myButton/${'myApp.language'}" but I want it to be: "dset:/label/myButton/@english". How to I add a variable to a string value in a <attribute> tag?

<canvas height="250" width="700" bgcolor="#D4D0C8" id="myApp">

<dataset name="dset" src="label.xml"/>

<attribute name="language" value="@english" type="string"/>
<attribute name="languagepath" value="dset:/label/myButton/${'myApp.language'}" type="string"/>

<script>
Debug.Write(myApp.language);
Debug.Write(myApp.languagepath);
</script>

</canvas>

caspar
03-02-2005, 08:24 AM
Can't you use the "oninit" and create the languagepath attribute in script there?

It would be something like:


<yourdatasettag>
<attribute name="language" value="@english" type="string"/>
<method event="oninit">

this.setAttribute("languagepath" , "dset:/label/myButton/" + this.getAttribute("language"));
</method>
</yourdatasettag>


You might need to &amp encode the '@' you use though..