top of script window
shockwave poll code snippet | show it | return |
movie handler
on update 
  global gSWPath
  
  -- initiate the net text call to read in current question
  getNetText (gSWPath & "q" & field "counter" & "/items")
  put "Loading question for Poll #" & field "counter" into field "msg"
  
  -- frame to wait for results
  go to frame "getText"
end
frame "getText" script
on exitFrame
  global gPollData, gSWPath

  if netDone() then
    -- line one has the question
    addProp gPollData, "q" & field "counter", line 1 of netTextResult()
    
    -- line 2 has the possible answers
    addProp gPollData, "a" & field "counter", line 2 of netTextResult()
    
    -- now grab the current results; append random variable
    -- so we get a server call to CGI (not from cache)
    GetNetText( gSWPath & "q"  & field "counter" & "/results?randy=" & the ticks)
    put "Loading results for Poll #" & field "counter" into field "msg"
    go to the frame + 1
  else
    go to the frame - 1
  end if
end
frame "getText" + 1 script
on exitFrame
  global gPollData
  
  if NetDone() then
    -- line 1 has results for each vote option
    addProp gPollData, "c" & field "counter", line 1 of netTextResult()
    
    -- line 2 the last date a vote was cast
    addProp gPollData, "lastvote" & field "counter", line 2 of netTextResult()
    go to frame "display"
    displayResults
  else
    go to the frame -1
  end if
end
The basic parts of talking to a CGI are to initiate the net call and then move to a looping frame to check the results. Later implementations would have a timer on the lopoing frame to check for no results from the server. A trick here was to find a way so that calls to the CGI were not drawn from cache, simply by appending a CGI variable that would always have a unique value (never used in ther actual CGI script) to make each called URL unique.

lingo era = v4-5