Spans work too, but you are right, if you want do some specific things you need override.html().desertfox wrote: ↑Wed Jun 12, 2019 1:44 am I'm a little rusty on the guideme/javascript but does a page normally look for a script var and expand it by just having it's name? I thought you had to use an override.html() function to change what text comes out during the java script. I haven't kept up on guideme changes though for a while. Hopefully someone who knows better can correct me if I'm wrong with anything.
Atleast that's my understanding.
Yes, I'm trying to not use global variables if I don't need to, but to show variable in span it needs to be global. Atleast I think based on my experience.desertfox wrote: ↑Wed Jun 12, 2019 1:44 am Another thing to think of is something called scope. (Sorry if going too basic not sure where you are at with programming concepts) Scope means essentially 'where do my variables live and for how long'. In your examplle, the 'var vTestAd' lives only as long as the pageLoad function, then it is gone. When you put it into the scriptVars though, it now lives as long as guideme lives in the scriptvars container.
You would put things into the scriptVars if you needed the information at a later time in the tease, which you could get with a get call. So whenever you put something into the script vars is just long term storage that you'll need on another page. If you are doing work for just that page you don't have to add it to scriptVars.
So it's important to know that they are two different things.Code: Select all
var vTestAd = "Why this doesnt???"; // local scope, gone as soon as pageload is done scriptVars.put("vTestAd", vTestAd); //you made a variable called vTestAd that contains the value if your local var ("Why this doesnt???").
Yes, the crucial part here is not to use spans inside spans. When you try to do it GuideMe will start to behave very strangely and inconsistantly.desertfox wrote: ↑Wed Jun 12, 2019 1:44 am So all in all I would write it something like this (based on what I learned when doing maze tease, also didn't test this).
Code: Select all
<Page id="StringsTesting"> <javascript> <![CDATA[ function pageLoad() { //These might be a scriptVars.get of an array of random words instead var vTestAd = "Why this doesnt???"; var vTestA = "Why this works???"; var vRandomStringX = "Lala" +vTestAd +"lala."; var vRandomStringY = "Lala" +vTestA +lala."; //html will just be a string of what will be written out on the page var html = "<p class=\"Text\"><span>" +vRandomStringX +"</span></p>" +"<p class=\"Text\"><span>" +vRandomStringY +"</span></p>" //Here you tell guideme to change the page text area to the string we built overRide.setHtml( html); } ]]> </javascript> </Page>
No, this was very helpful. I've finally solved my problem and made this keyword substitution work properly.
My problem was:
1) Using spans in spans
2) Not understanding how to properly initialize and later change variables/keywords in my text arrays
Now it finally works and I like the result! It's not magic but it's one more step towards more variety.
The next logical step to improve quality of the text is creating personality modules and using more and more and more context. That's seems like a more long term problem and I'll work on it as I expand my tease.
Thanks Desertfox!