Another unusable name.

Workarounds and usability notes.

Another unusable name.

Postby John Robin Dove » Sun Dec 20, 2020 10:15 am

Hi Clifton,

I have just discovered that you cannot use the name 'userGroup' in an XML file. Here is my code:
<AGroup>
<pgStyleObject>
<![CDATA[
{ theStyle : "cursor",
propVal : "pointer,"}
]]>
</pgStyleObject>

<function name="myTrigger" event="trigger" params="" useTB="true">
<![CDATA[
tbfunction_pgTimer(false, 750, "AGroup");
tbfunction_pgTimer(false, 8000, "recorder"); //After 8 seconds the audio player will be displayed
]]>
</function>

<function name="myUser" event="user" params="evt,value" useTB="true">
<![CDATA[
if (!(keys.timesAllowed == 0))
{
tbfunction_pgTBObjSet("AGroup", "visible", false);
}
]]>
</function>
</AGroup>


If you change AGroup to userGroup this error message appears: SyntaxError: missing ) after formal parameters (line number 5) Perhap you knew about this. If not beware :)
John

UPDATE
Maybe it's not the name. I have have just got the same error message with another name 'pleaseWait' which is unlikely to be reserved for the system.

UPDATE 2
Once again, simply changing the name solves the problem. I changed it from <pleaseWait> to <waitGroup>. Not sure what's going one here.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Another unusable name.

Postby Clifton » Sun Dec 20, 2020 1:56 pm

Hi John,
I cannot seem to duplicate issues involving <userGroup> tags.
Here is my example:

And here is the XML for this example:

I can assure you it is not the name. It could be another tag which relies on this. When the interpreter tells you something like:
SyntaxError: missing ) after formal parameters (line number 5)
It means that there is an error somewhere in your code and that the xml engine cannot entirely compile the file. To diagnose this, I usually start by commenting out functions to find the errant one that is causing the compiler problem. Then, if I can't see it, I will narrow the function down by commenting out lines until I find the one with the problem. Sometimes these things are easy to see and other times it can be a little harder to spot the problem. Tag name issues do not throw these types of errors. The issue is usually with a sub-tag of tag name like a function, etc. In your case, try removing the comma after the style "pointer,".

 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Another unusable name.

Postby John Robin Dove » Mon Dec 21, 2020 7:46 am

OK problem solved. Sorry to have wasted your time. The explanation suddenly dawned on me this morning. I am converting each of my original tbk files to 'empty tbk + Powerpac xml' format because their current hybrid form tbk + extra js file + Powerpac xml file makes them almost impossible to debug. Trying to find things via the Toolbook dump actions txt file is not really an option either. So I am going through the objects one at a time and converting all the code to the Powerpac xml format. Once that is done the project becomes viable again. It's like opening the shutters in a dark room. I think I have converted about two thirds of the project but it's tedious work. I normally delete all the code in the tbk file as soon as it has been transferred to the xml and then re-export the tbk. This time I forgot to re-export the tbk. So the original TB actions editor code must have been conflicting with the new code in the xml which explains why certain names were affected but not others.

PS I have learnt that the complete xml file must be tested after each new addition otherwise finding syntax errors is like looking for a needle in a haystack!
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Another unusable name.

Postby Clifton » Mon Dec 21, 2020 12:14 pm

After a while, you will get pretty good at interpreting the debug messages that appear when each XML file loads and finds a problem. Most problems are related to missing quotes, commas, and semi-colons. The interpreter will generally flag these pretty good. I still find just commenting out sections like this works best to narrow down where a problem is. In the XML code below comments are in green. Some are blocking entire code sections. (See the function at the end of all of this code which contains an error preventing the XML from compiling; can you find it?)
<?xml version="1.0" encoding="utf-8"?>
<page>
    <config delay="">
        <!--Configuration tags (e.g.: <stylesheet> and <javascript> tags;
         can also include PowerPac function tags; etc.)-->
        <stylesheet>
            ../xml_config/normal.css
        </stylesheet>
    </config>

    <page>
        <!--Prevent ghost image from appearing on background image-->
        <pgStyleObject>
            { theStyle : 'pointerEvents',
             propVals : 'none' }
        </pgStyleObject>

        <function name="preventDrag" event="" params="evt" useTB="true">
            <![CDATA[
                /* CLIFTON: Executed when user clicks on a link.
                            Idea is to prevent behavior like dragging, etc.
                    TO USE: (code example)
                        <a href="#" onclick="parent.tbfunction_gotoNextPage();"
                                ondragstart="parent.tbfunction_pgTBObjSet('page', 'preventDrag', [window.event]);">
                        Start Lesson</a>
                ***/

                if (typeof evt != 'object' || !evt.type) {
                    evt = window.event; //Get current window event
                }
                if (evt.preventDefault) {
                    evt.preventDefault();
                }
                return false;
            ]]>
        </function>

        <function name="myUnload" event="unload" params="e" useTB="true">
            <![CDATA[
                if (this.audioTmr) clearTimeout(this.audioTmr || 0);
            ]]>
        </function>

    <CCButton>
        <pgStyleObject>
            { theStyle : 'boxShadow',
             propVals : '5px 5px 5px 0px rgb(77, 85, 107)' }
        </pgStyleObject>

        <function name="myClick" event="click" params="evt,undef,target,mX,mY,isShift,isCntrl" useTB="true">
            <![CDATA[
                /* CLIFTON: Process a change in whether to use closed captions.
                ***/

                var args = [ evt, tbfunction_pgTBObjGet(this.name, 'checked') ];
                tbfunction_pgTBObjSet('sharedActions', 'closeCaptionEvent', args);
            ]]>
        </function>

        <function name="myLoad" event="load" params="e">
            <![CDATA[
                /* CLIFTON: If closed captioning videos are NOT available, then this button
                           must remain hidden from view (style.display = 'none').
                    NOTE: See book.xml where allowCC is set on book load.
                         The setting is global for all pages, but can be changed for individual pages.
                ***/

                var allowCC = gTBo('sharedActions', 'objRef').allowCC, disp = '-';
                if (!allowCC) {
                    tbfunction_eraseCookie('TecEaseCC');
                    disp = 'none';
                }
                tbfunction_pgStyleObject(this.name, 'display', disp);
            ]]>
        </function>
    </CCButton>

    <FullscreenToggle>
        <!--This object is the lower right corner graphic that clips the video player.-->
        <pgStyleObject>
            { theStyle : 'cursor',
             propVals : 'pointer' }
        </pgStyleObject>

        <function name="mousey" event="mouseover" params="e">
            <![CDATA[
                /* CLIFTON: Show the controls when mouse event occurs on this object.
                ***/

                var mediaContainer = gTBo('sharedActions', 'objRef').mediaContainer, status;
                if (mediaContainer) {
                    status = tbfunction_htmlVideoControl(mediaContainer, 'status');
                    if (status) {
                        tbfunction_pgStyleObject(this.name, 'cursor', 'pointer');
                        tbfunction_htmlVideoControl(mediaContainer, 'controls', true);
                    } else {
                        tbfunction_pgStyleObject(this.name, 'cursor', '-');
                    }
                } else {
                    tbfunction_pgStyleObject(this.name, 'cursor', '-');
                }
            ]]>
        </function>

<!--I think there might be a problem with this function.
So I reload the page with this section commented out!
CAN YOU FIND IT???

        <function name="myClick" event="click" params="evt,undef,target,mX,mY,isShift,isCntrl" useTB="true">
            <![CDATA[
                /* CLIFTON: Clicking this object will force the video to go to fullscreen. This
                           has been provided because this graphic partially obstructs the fullscreen
                           button in the control bar of the [VideoPlayer].
                ***/
                var mediaContainer = gTBo('sharedActions', 'objRef').mediaContainer, status, controls;
                if (mediaContainer) {
                    status = tbfunction_htmlVideoControl(mediaContainer, 'status');
                    if (status) {
                        controls = tbfunction_htmlVideoControl(mediaContainer, 'controls);
//BINGO! It is on this line!
                        if (controls) {
                            tbfunction_htmlVideoControl(mediaContainer, 'fullScreen', 'enter');
                        } else {
                            tbfunction_pgStyleObject(this.name, 'cursor', '-');
                        }
                    }
                }
            ]]>
        </function>
-->
    </FullscreenToggle>
</page>
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Another unusable name.

Postby John Robin Dove » Tue Dec 22, 2020 5:33 am

Thanks for your reply which I have only just seen. Yep, missing single quote after 'controls. I have become very accustomed to this sort of problem. I could show you dozens except that I don't save them. Maybe I should. The longest search to find an error was about two or three hours I think. That was because I had saved the error the day before and then forgotten which part of the 7000 line file I had been working on. Nowadays I always test the file before backing it up at the end of the day. An additional complication is that the parser often signals a missing ")" when the real problem is within the brackets. A common one for me is a missing comma after one of the arguments. Another mistake I sometimes make is writing a space instead a period like sharedActions fileName instead of sharedActions.fileName. I think this because I hear it in my brain and write down what I hear.

I'm not much of a typist either. I should follow your course. The trouble is I don't have time. Maybe I'll do it when all this is finished. I was hoping to finish before Christmas but I think I'll probably need a month or two after that to mop up the last pockets of resistance. :D
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Another unusable name.

Postby Clifton » Tue Dec 22, 2020 8:43 am

7000 line file?!!
That is a big file.
You can easily break up big files into < 1000 line chunks. Makes searching for problems a lot easier. Each file can be load inside the one before it.
tbfunction_XMLHttpRequest("Get", [url to my linked xml module], "", [set notify to either "page" or "nouser"], true);


If the interpreter has a problem with a specific file in the chain, then it will flag only that file.
Even though you are well along in your project, it is easy to basically break files into more manageable chunks and give those "modules" meaningful names.
PHP programmers break up their files into sections and then use the request(), include [file], or request_once() to add them when needed.

Another thing that helps to avoid typos is to consider the editor you are using. I've built one into the PowerPac and even though I use others, I
currently always come back to the PowerPac one (which uses NotePad3). It is fast, not too complicated and its syntax highlighting and code-folding features work great for XML editing. You can zoom the code with the mouse and mark lines for quick reference.
    (However, while NotePad3 is made by Rizone, I do not recommend their latest version. It has gotten bulky and slow in my opinion. I am monitoring this and as soon as that changes, I will probably include it in the PowerPac.)
Just a thought but I'm sure you know whether this approach would work in your specific case.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Another unusable name.

Postby John Robin Dove » Tue Dec 22, 2020 2:01 pm

Thanks for your advice. I must confess I had not noticed that you provide a code editor. I am too busy bashing away, trying to get this project finished to notice much at all. I am still using SynWrite that you recommended a few years ago.

Yes, I guess it would be more logical to use smaller files. On the other hand it's no longer a problem because every time I add a new block of code I test it. This way the needle in the haystack scenario is avoided.

The other day you wrote: you may want to begin using "private" session cookies. They are already encrypted and stored in the DOM (top level parent window) just in case the browser rejects storing session cookies because of user preferences. So, if I understand you correctly, I can use this type of cookie without having to encrypt any data. At the moment I use session cookies but I encrypt the data myself and decrypt it when I need it. Can I access a "private" session cookie from a page embedded in an iframe? Maybe I should provide a function in the top page to do that?

One other thing. I think I really have found a forbidden word this time :) I use an object called 'keys' to store global variables. It is identical to the 'sharedActions' object that you gave me. In the tbk actions editor version I had a variable called prefix so it became keys.prefix. This does not work. keys.prefix returns null but if I call it keys.myPrefix there is no problem.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Another unusable name.

Postby Clifton » Tue Dec 22, 2020 4:10 pm

Regarding "prefix" ...
Cookies are available in all same domain pages, so you shouldn't have a problem. However, the PowerPac handles the encryption of private session cookies, so you will need to let the PowerPac decrypt the cookie when you need to read it back. You could use pgExecuteRemote() to handle this by calling tbfunction_readCookie(), etc.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron