Language switch via data: ?

  • Hi,
    beside switching between different language content via different folders (https://krpano.com/forum/wbb/inde…&threadID=17499) I need to open different URLs depending on the choosen language.

    My idea is, to simply use a data: set to store the links. Is it possible to do this?

    e.g.:


    I know the last part is not right, but I have missed the right way to transform the data.content into a variable or use it directly to open the url. I tried several things, but I'm a bit worried, that I'm on the wrong track completely.

    Code
    <action name="a_openlocalizedurl">
    					trace(data[url_infopoint-%1-%2].content);
    <!--					set(urlloc,data[url_infopoint-%1-%2].content);-->
    					copy(urlloc, get(data[url_infopoint-%1-%2].content));
    	</action>


    I very much would appreciate some hint, why this is not working.

    Yours,

    Michael

  • you're not on the wrong track, you can do it that way ...

    seems more a problem of understanding set, get and copy (?)
    ---> if a and b are variables

    your code:
    set(a,b); --> a = "b", not the content of b
    copy(a, get(b)); --> you could do that if b="c" and you want the content of variable c (is not the case here)

    what you want is: set(a, get(b)); --> a = content of b
    or shorter: copy(a, b); --> a = content of b

    most krpano actions expect direct content for their arguments, not variables
    for these you need get() to replace the variable by its content
    exceptions are : copy, trace, debug, error, warning (and some others)

    for your thing this probably works... (openurl expects an url, not a variable)

    Code
    <action name="a_openlocalizedurl">
        openurl(get(data[url_infopoint-%1-%2].content));
    </action>

    (untested)

  • "copy(a, get(b)); --> you could do that if b="c" and you want the content of variable c (is not the case here)"
    "most krpano actions expect direct content for their arguments, not variablesfor these you need get() to replace the variable by its content

    exceptions are : copy, trace, debug, error, warning (and some others)"


    Thanks so much for this insight!! I have been bashing my head on a keyboard for two straight days and this was the solution. Seriously, I clocked 8 hours trying to fix a bug caused by this *cry* . I am writing a similar piece of code to what Mstoos is trying, except in my case the data element contains a huge list of values/text/addresses that are bracketed by unique identifiers. So I was making a "retrieve" action that looks for those unique bracketing identifiers and extracts the values/text/address. If anyone wants the action just say so and I'll clean it up and post it (not that it is terribly complicated, but maybe I can help some one from troubleshooting something similar).


    I guess my mistake was I had a situation where a = "b". Then when I was troubleshooting why the action wasn't resolving correctly, I found my self using trace. Trace('the value of a is: ', get(a)) would return the correct value, so I made the assumption that the correct value was being passed on to the rest of my action!


    Thanks Indexofrefraction for taking the time to clarify this nuance of Krpano. *thumbup*

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!