Forcing Screen Updates

Discussion in 'Javascript' started by Gene Wirchenko, Nov 25, 2011.

  1. Dear JavaScripters:

    The text that I am using has a tictactoe game that shows the use
    of frames. What a bother to get it going, but I have.

    An oddity is that the winning move is sometimes shown before the
    alert about winning or losing, and sometimes, it is shown after. There
    might be a race condition going on.

    Is there any way to force screen updating to be complete before
    displaying a modal?

    I have Web-searched for an answer, but have not found anything
    useful. I tried using setTimeout(), but that screwed up execution in
    a way that I have not figured out.

    This does have a practical use. In a data entry form, I might
    want to correct some entries, tell the user to check the changes, and
    confirm them. It is more difficult when the changes have not shown up
    yet.

    Sincerely,

    Gene Wirchenko
     
    Gene Wirchenko, Nov 25, 2011
    #1
    1. Advertising

  2. On Nov 25, 2:00 am, Gene Wirchenko wrote:
    > Dear JavaScripters:
    >
    > The text that I am using has a tictactoe game that shows
    > the use of frames. What a bother to get it going, but I have.


    So would that be a 3 by 3 grid of frames into which some external
    resource is loaded in order to show the zero, cross or blank state of
    that position in the grid?

    > An oddity is that the winning move is sometimes shown before
    > the alert about winning or losing, and sometimes, it is shown
    > after. There might be a race condition going on.


    Content loaded into frames is likely to be loaded asynchronously,
    which might result in varying loading intervals (with varying
    conditions such as network load) and varying parsing/rendering time
    (with varying things such as CPU load). It may be that when the URL
    for the individual frame is set sometimes the content arrives and is
    processed/rendered quickly and at other times it takes longer to
    arrive or render.

    > Is there any way to force screen updating to be complete
    > before displaying a modal?


    That would be irrelevant if the issue is the timing of loading
    external resources. It is certainly possible to arrange to be aware of
    the completion of loading of external resources into frames. For
    example, if the resource being loaded is an HTML page it could include
    a script that is triggered - onload - that tells the containing
    frameset page that it has arrived. Thus the containing frameset page
    could keep track of which instructions it had issued to particular
    frames to load external resources and which eternal resources had
    announced their arrival, and so know when everything was in place for
    it to do whatever next step it was intending.

    > I have Web-searched for an answer, but have not found
    > anything useful. I tried using setTimeout(), but that screwed
    > up execution in a way that I have not figured out.
    >
    > This does have a practical use. In a data entry form,
    > I might want to correct some entries, tell the user to check
    > the changes, and confirm them. It is more difficult when the
    > changes have not shown up yet.


    Usual form validation of that sort is carried out by client-side
    script prior to submitting the form and so cancels the submit action
    if corrections need making, (and/)or it is carried out by server side
    scripts that return the form asserting which corrections need making.
    In neither of those cases would require worrying about screen updates
    as only the latter requires that the form be re-rendered and it
    arrives to be re-rendered at exactly the same time as the information
    that the user needs to correct something.

    Richard.
     
    Richard Cornford, Nov 25, 2011
    #2
    1. Advertising

  3. Gene Wirchenko

    Tim Streater Guest

    In article
    <>,
    Richard Cornford <> wrote:

    > On Nov 25, 2:00 am, Gene Wirchenko wrote:
    > > Dear JavaScripters:
    > >
    > > The text that I am using has a tictactoe game that shows
    > > the use of frames. What a bother to get it going, but I have.

    >
    > So would that be a 3 by 3 grid of frames into which some external
    > resource is loaded in order to show the zero, cross or blank state of
    > that position in the grid?


    Yes, he means noughts-and-crosses.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
     
    Tim Streater, Nov 25, 2011
    #3
  4. On Fri, 25 Nov 2011 06:26:58 -0800 (PST), Richard Cornford
    <> wrote:

    >On Nov 25, 2:00 am, Gene Wirchenko wrote:
    >> Dear JavaScripters:
    >>
    >> The text that I am using has a tictactoe game that shows
    >> the use of frames. What a bother to get it going, but I have.

    >
    >So would that be a 3 by 3 grid of frames into which some external
    >resource is loaded in order to show the zero, cross or blank state of
    >that position in the grid?


    Yes.

    >> An oddity is that the winning move is sometimes shown before
    >> the alert about winning or losing, and sometimes, it is shown
    >> after. There might be a race condition going on.

    >
    >Content loaded into frames is likely to be loaded asynchronously,
    >which might result in varying loading intervals (with varying
    >conditions such as network load) and varying parsing/rendering time
    >(with varying things such as CPU load). It may be that when the URL
    >for the individual frame is set sometimes the content arrives and is
    >processed/rendered quickly and at other times it takes longer to
    >arrive or render.
    >
    >> Is there any way to force screen updating to be complete
    >> before displaying a modal?

    >
    >That would be irrelevant if the issue is the timing of loading
    >external resources. It is certainly possible to arrange to be aware of
    >the completion of loading of external resources into frames. For
    >example, if the resource being loaded is an HTML page it could include
    >a script that is triggered - onload - that tells the containing
    >frameset page that it has arrived. Thus the containing frameset page


    That sounded like a good idea. I decided to try it.
    Unfortunately...

    The pages that display X and O already have a form onload. They
    are to the routines testing for loss/victory and include the alert()s
    that are getting displayed before the page is.

    onload firing means that the page has been loaded. I am now
    wondering what "loaded" means? Can I count on the page being
    displayed at this point? It appears not. How can I determine that
    the page has been displayed?

    >could keep track of which instructions it had issued to particular
    >frames to load external resources and which eternal resources had
    >announced their arrival, and so know when everything was in place for
    >it to do whatever next step it was intending.


    Is onload the correct event for determining this?


    I did manage to kludge a solution. I really would like a
    non-kludge solution.

    The onload()s call ShowLoser() and ShowWinner() which have a
    check and display an alert() if the game is over. I changed each to
    if the check, then set a timeout and call a display function. The
    display function simply has an alert().

    I had to guess for an appropriate timeout value and started with
    1000 ms. However, I tried cutting it down and got it down to 0!


    Searching further, I have also now seen document.readyState. I
    tried using that, but I can not seem to access values in ShowWinner()
    unless they were declared in it, even a global! Something strange is
    going on.

    >> I have Web-searched for an answer, but have not found
    >> anything useful. I tried using setTimeout(), but that screwed
    >> up execution in a way that I have not figured out.
    >>
    >> This does have a practical use. In a data entry form,
    >> I might want to correct some entries, tell the user to check
    >> the changes, and confirm them. It is more difficult when the
    >> changes have not shown up yet.

    >
    >Usual form validation of that sort is carried out by client-side
    >script prior to submitting the form and so cancels the submit action
    >if corrections need making, (and/)or it is carried out by server side
    >scripts that return the form asserting which corrections need making.
    >In neither of those cases would require worrying about screen updates
    >as only the latter requires that the form be re-rendered and it
    >arrives to be re-rendered at exactly the same time as the information
    >that the user needs to correct something.


    I would not be using it that way necessarily. If I catch an
    error before submitting is selected by the user, I would still want to
    make such corrections. I would want that the display is updated
    before the alert() is display.

    So, my queston stands.

    Sincerely,

    Gene Wirchenko
     
    Gene Wirchenko, Nov 25, 2011
    #4
  5. In comp.lang.javascript message <esstc7144g17f0vnpeodg4aiv3iid8357m@4ax.
    com>, Thu, 24 Nov 2011 18:00:04, Gene Wirchenko <> posted:

    > The text that I am using has a tictactoe game that shows the use
    >of frames. What a bother to get it going, but I have.
    >
    > An oddity is that the winning move is sometimes shown before the
    >alert about winning or losing, and sometimes, it is shown after. There
    >might be a race condition going on.


    The situation is perfectly clear. You have a design or coding error in
    your script. But it is hard to say what, or where, it is.

    If you were to read the newsgroup FAQ, or ECMA 262 edition 5.1, or my
    Web site, you might well do better. Try all three.

    BTW, please do not assume that the generality of readers is familiar
    with all Americanisms/Canadianisms. Use the international subset of
    English, if you can.



    If you want to be sure that the winning move is announced after it is
    shown, let the code execution come to a natural end after the winning
    move is shown. Immediately before that end, put

    var Good, Result ;
    // Good = ...
    Result = Good ? 'win' : 'lose'
    setTimeout("alert('" + Result + "')", 1000)

    or, better

    function Show() { alert(Result) }
    var Good, Result ;
    // Good = ...
    Result = Good ? 'win' : 'lose'
    setTimeout(Show, 1000)

    The 1000 is for initial test; unless redrawing your game is unreasonably
    complex, 10 should do. Therefore, consider 50 or 100.

    There may, and probably should, be an explicit Method for redrawing the
    screen, and optionally waiting until that is finished..

    --
    (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
    Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
    PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
    Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
     
    Dr J R Stockton, Nov 26, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russell
    Replies:
    1
    Views:
    383
    Steve C. Orr [MVP, MCSD]
    Jan 21, 2004
  2. Kris Dugan

    Need constant screen with periodic updates

    Kris Dugan, Jun 7, 2004, in forum: C Programming
    Replies:
    8
    Views:
    357
    Thomas Dickey
    Jun 8, 2004
  3. Greg Smith

    Forcing browser to full screen

    Greg Smith, May 29, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    468
  4. robert
    Replies:
    1
    Views:
    105
    Martin Honnen
    Aug 23, 2003
  5. Kris Dugan

    Need constant screen with periodic updates

    Kris Dugan, Jun 7, 2004, in forum: Perl Misc
    Replies:
    11
    Views:
    238
    Joe Smith
    Jun 9, 2004
Loading...

Share This Page