Page 1 of 1
unicode label of button
Posted: Wed Apr 20, 2016 10:38 pm
by ittzy
Hi im trying to use unidecode for Scandinavian letters, im trying to put it on a label of an button but i cant get it to work.
It works perfekt with field, here is the code fo my field:
Code: Select all
put uniDecode (the unicodetext of field "h_namn" of stack "fotboll_installningar", "UTF8") after xml
I tried to just change word fld to btn but i guess that is totally wrong..

Here is what im talking about, in my buttons you can see the letters but in my template they dont show. But if i but those names in a field they will show
.igor
Re: unicode label of button
Posted: Wed Apr 20, 2016 11:54 pm
by dunbarx
Hi.
Buttons are containers, just like fields. Your handler likely works fine, but you are not seeing what is really happening. Try this. Make a button on a new card. In the message box:
put "5" into btn 1
add 1 to btn 1
answer btn 1
Now where is that "6"? It is in button 1 just as if it was in a field. But you do not see it, because buttons don't work exactly like fields do. What you really want is to deal with the label of that button. Different property:
Code: Select all
put uniDecode (the unicodetext of the label of btn "yourButton" of stack "fotboll_installningar", "UTF8") after xml
Craig Newman
Re: unicode label of button
Posted: Thu Apr 21, 2016 8:20 am
by ittzy
hi craig, thx for you help.
I didn't get that first part to try to put 5 in a button?
I tried that string you wrote but i get an error when im trying to press my button
button "h_byte": execution error at line 38 (Chunk: error in object expression) near "3 Henrik Ädehl", char 41
Re: unicode label of button
Posted: Thu Apr 21, 2016 3:37 pm
by jacque
If you are using LC 7 you don't need to use unidecode. LC 7 automatically works with any character set. Just set the label to the Scandinavian string normally, just as though it were Roman text. The same is true for the XML template.
The only time you need to manage unicode translation is when you are exporting or importing text outside of LC. In those situations use textEncode and textDecode.
All the older unicode text properties are deprecated now. They are still available for legacy stacks but are not necessary for new work.
Re: unicode label of button
Posted: Thu Apr 21, 2016 3:45 pm
by dunbarx
What happens if you place this into a button script:
Code: Select all
put "5" into btn me
add 1 to me
answer me
You do not see the 5 or the 6, because the contents of a button are not visible. But they are there, since the button is a valid container.
So buttons have labels, which are visible. They may contain data, which is invisible. Fields have labels, but they are invisible. Then may contain data, which is visible.
Craig
Re: unicode label of button
Posted: Thu Apr 21, 2016 8:20 pm
by ittzy
I understand that, im using the label in other functions. But now when im trying to show the label of the button in my template it does not show the Scandinavian letters or other not roman letters.
I use LC7, in LC it shows the letters but its when im sending the data to a template it gets wrong.
Re: unicode label of button
Posted: Thu Apr 21, 2016 8:30 pm
by jacque
ittzy wrote:I use LC7, in LC it shows the letters but its when im sending the data to a template it gets wrong.
If your template is another file on disk, you need to use textEncode before writing it to the file:
Code: Select all
put textEncode(field "h_namn" of stack "fotboll_installningar", "UTF8") after xml
When you read the xml file back into LiveCode, decode it:
Code: Select all
put textDecode(tTemplateText,"UTF8") into xml
These two functions replace the old uniEncode and uniDecode functions. You only need to use them when importing or exporting text to a non-LiveCode destination.
Re: unicode label of button
Posted: Thu Apr 21, 2016 8:44 pm
by ittzy
Here is the part of that code that gets a error.
Code: Select all
put "<componentData id=\" after xml
put quote after xml
// Flashbox
put "h_spelare1\" after xml
put quote after xml
put "><data id=\" after xml
put quote after xml
put "text\" after xml
put quote after xml
put " value=\" after xml
put quote after xml
//Field Livecode
put uniDecode (the unicodetext of the label of btn "h_in", "UTF8") after xml
put "\" after xml
put quote after xml
Re: unicode label of button
Posted: Thu Apr 21, 2016 9:17 pm
by jacque
What do you do with the xml text? Do you use it only in LiveCode? Are you writing the xml to a file? The script shouldn't use uniDecode when creating the xml:
Code: Select all
put "<componentData id=\" after xml
put quote after xml
// Flashbox
put "h_spelare1\" after xml
put quote after xml
put "><data id=\" after xml
put quote after xml
put "text\" after xml
put quote after xml
put " value=\" after xml
put quote after xml
//Field Livecode
put the label of btn "h_in" after xml -- use this text normally
put "\" after xml
put quote after xml
If you save the xml to a text file on disk, use the textEncode function before writing the file and use textDecode when reading the file. If you are saving the template in the stack, you don't need to do anything special with the text, it is already in the correct format for LiveCode.
Re: unicode label of button
Posted: Thu Apr 21, 2016 9:55 pm
by ittzy
hi im not writing a xml thats just instead of myvariable (just a text) when i was learning livecode a guy showed my a bit of code and i kept useing that "xml".
As i wrote, im sending this text to a flash template.
When i use it like you told me "put the label of btn" my letters as å,ä,ö does not show but everything els show so fot example if i write "Igår" it shows "Igr" in the template. But i LC i see all the letters
usually i would write this if it was a fld and it works perfekt... put uniDecode (the unicodetext of field "name of fld", "UTF8") after myVariable
Now i need to get it to work with btn label
Re: unicode label of button *solved*
Posted: Sun Apr 24, 2016 3:27 pm
by ittzy
Unicodelabel