Don't know how to explain this in a short message, but here is a try.

We have a page on our site that display some basic information about a customer. After the basic information, I have three areas that you can optionally display "Contacts", "Jobs", and "Documents". I use a pair of little triangular gifs to open or close those area. The state (open or closed) is kept in a session variable. This worked fine until a couple months ago when I tried to clean up the code and moved those three areas to an "include" call. I guess it has been broken since then but we have not noticed it since the default state satisfies most users needs. The toggle works the first time and dumping the session variables, it appears to set the correct state. But if I refresh or toggle the same area, the session variables seem to have reverted back.

Now that sure sounds like I have a bug in my code and my toggle is being called twice - reverting the state to the original. Not finding anyway that it could be called twice, I wrote a small simulation to see if it could be Active4D. I once again proved that blaming someone else usually will not solve the problem. The simulation work flawlessly! The simulation is included below in case my words are not describing the problem. Basically we start with our main page (foomain) that has a link to the customer display area (foosub) that has the basic information and the optional information (foo1,2&3).

I put dump session calls at the entry and exit of the customer area and kept seeing this double toggle. The session variable is only set at one point and putting a dump trace in that area indicates that it was not being called twice.

The last thing I tried was on exiting the sub program, I set a session variable to the current timestamp. As expected, the session dump at the beginning did not contain the timestamp, and the session dump at the end did. On refresh or toggle, the timestamp shows up in the beginning dump but is usually 500ms or so latter than the last ending timestamp. By the way, I put the dumps and the beginning and end of the main page with the same results.

Any idea on how to set a trap for this little bugger? Three of us have looked at the code, analyzed the dumps and all conclude that somehow the code is being called twice - but there is only one dump. The simulation works, but it does not have all the other code that makes up the page.

Steve Alex
AIDT


------------- Simulation -----

<% // foomain.a4d - simulate our main page, almost all code comes thought the main page
write("FooMain..<br>")
include("FooSub.a4d") // simulates call to customer area
%>


<% // foosub.a4d
dump session
write("FooSub..<br>")
if(session has("foo"))
if(defined($toggle))
set session($toggle; not(get session($toggle))) // flip toggle
end if
else
set session("foo";true;"foo1";true;"foo2";true;"foo3";false) // set initial state
end if


        include("foo1.a4d") // contacts
        include("foo2.a4d") // jobs
        include("foo3.a4d") // documents
        set session("foots";timestamp)
        dump session
%>

<%  // foo1.a4d   (foo2 & f003 same, except for numbers (1,2 or 3))
        $myToggle := get session("foo1")
        write("Foo1..<a href=\"?toggle=foo1\">"+$myToggle+"</a><br>")
        if($myToggle)
                write("&nbsp;More 1 stuff because open<br>")
        end if
%>

--------- Timestamps taken from session dump on one test run of real code

initial load
<blank> in
20041109210158664 out

refresh page
20041109210159208 in 544ms diff
20041109210307457 out

toggle contact
20041109210307105 in 352ms diff
20041109210506071 out

toggle again
20041109210507621 in 1548ms diff
20041109210555742 out

_______________________________________________
Active4D-dev mailing list
[EMAIL PROTECTED]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to