Storing/retrieving data from a notepad

Posted by Stratus on Sat 04 Jan 2003 08:33 PM — 2 posts, 11,577 views.

#0
Ok, I've been trying to make a poll.
Trigger: (*: Poll.
Enabled: Checked
Ignore Case: Checked
Label/Script: Poll

sub Poll (thename, theoutput, thewildcards)
dim Name
Name = world.gettriggerinfo (thename, 101)
world.send """Well hello there, " + Name + ". Todays poll is: Who will win the Steelers VS. Browns game?"
world.enabletrigger "Vote", TRUE
end sub

Trigger: (*: Vote: *
Ignore Case: Checked
Label/Script: Vote

sub Vote (thename, theoutput, thewildcards)
dim Name
dim Vote
dim Vote2
dim fVote
Name = world.gettriggerinfo (thename, 101)
Vote = world.gettriggerinfo (thename, 110)
Vote2 = LCASE(Vote)
fVote = RIGHT(Vote2, 9)
if fVote = "steelers." then
world.send """Your vote has been registered as the Steelers. #SA"
elseif fVote = ": browns." then
world.send """Your vote has been registered as the Browns. #SA"
else
world.send """Error: Vote did not register. Please try again."
end if
world.enabletrigger "Vote", FALSE
end sub

Now, the whole thing works fine. But I need to know how to save the persons vote into a text file and how to retrieve it. Also I was wondering if there was a way I could add them in the notepad so it would give me the total votes for each team.
Australia Forum Administrator #1
I would put the whole lot in a plugin, put the votes into variables, and save the plugin's state. That would keep the responses over different sessions. eg.

world.setvariable "vote_" & person, team

where "person" is the person voting and "team" is who they vote for.

Then you could use "getvariablelist" to get all variables, find the ones starting with "vote_" and add to a counter for each team. then send to the notepad the totals (or do a world.note).

Alternatively you could use a database to store the results, there are a couple of example plugins that show how to write to a database and get the results back.