New 'subtxt' action for dummies (like me): solved

  • I decided to give the new function 'subtxt' a go.
    I couldn't make it wok until I realised that it was because of my coding skills, rather than a bug.
    I've decided to post it here just in case it can be helpful to future generations *smile*

    So here is the scenario:

    Code
    <krpano version="1.0.8.14" onstart="action(testsubtxt, pano4);"> 
    <action name="testsubtxt">	
    	trace(%1);	
    	subtxt(pano_number,%1,4);	
    	trace(get(pano_number));
    </action>


    Output:
    INFO: pano4
    INFO:

    So it returns nothing. Why? Well, it's not the first time I've made this mistake using %1 params.
    Because I can trace %1 value, it makes me think it's a variable already defined, but its' not.
    So to make it work I have define %1 as a variable, obviously...

    Code
    <krpano version="1.0.8.14" onstart="action(testsubtxt, pano4);"> 
    <action name="testsubtxt">	
    	trace(%1);	
    	set(%1, %1);	
    	subtxt(pano_number,%1,4);	
    	trace(get(pano_number));
    </action>


    Output:
    INFO: pano4
    INFO: 4

    Or something like this (a bit clearer):

    Code
    <krpano version="1.0.8.14" onstart="action(testsubtxt, pano4);"> 
    <action name="testsubtxt">	
    	trace(%1);	
    	set(first_param, %1);	
    	trace(first_param);	
    	subtxt(pano_number, get(first_param),4);	
    	trace(get(pano_number));
    </action>


    Output:
    INFO: pano4
    INFO: pano4
    INFO: 4

    Thank you Klauss to make Krpano xml code even more powerful. I can wait to start using the new functions to create loops!

    Cheers!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!