Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Polls and Notepad
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Stratus
(25 posts) Bio
|
Date
| Thu 13 Mar 2003 03:26 AM (UTC) |
Message
| sub Poll (thename, theoutput, thewildcards)
dim Name
Name = world.gettriggerinfo (thename, 101)
world.send """Well hello there, " + Name + ". Todays poll is: Who's cooler, Intro or Naveah?"
world.enabletrigger "Vote", TRUE
end sub
sub Vote (thename, theoutput, thewildcards)
dim Name
dim Vote
dim Vote2
dim fVote
dim Intro
dim Naveah
Name = world.gettriggerinfo (thename, 101)
Vote = world.gettriggerinfo (thename, 110)
Vote2 = LCASE(Vote)
fVote = RIGHT(Vote2, 6)
SELECT CASE fVote
Case "intro."
world.send """Your vote has been registered as Intro. #SA"
world.activatenotepad "Poll"
world.appendtonotepad "Poll", "1 | " + Name
world.appendtonotepad "Poll", vbcrlf
world.SaveNotepad "Poll", "c:\Program Files\Mushclient\Poll", 0
Case " intro"
world.send """Your vote has been registered as Intro. #SA"
world.activatenotepad "Poll"
world.appendtonotepad "Poll", "1 | " + Name
world.appendtonotepad "Poll", vbcrlf
world.SaveNotepad "Poll", "c:\Program Files\Mushclient\Poll", 0
Case "aveah."
world.send """Your vote has been registered as Naveah. #SA"
world.activatenotepad "Poll"
world.appendtonotepad "Poll", "2 | " + Name
world.appendtonotepad "Poll", vbcrlf
world.SaveNotepad "Poll", "c:\Program Files\Mushclient\Poll", 0
Case "naveah"
world.send """Your vote has been registered as Naveah. #SA"
world.activatenotepad "Poll"
world.appendtonotepad "Poll", "2 | " + Name
world.appendtonotepad "Poll", vbcrlf
world.SaveNotepad "Poll", "c:\Program Files\Mushclient\Poll", 0
end SELECT
world.enabletrigger "Vote", FALSE
end sub
Now this whole thing works like magic *but* when I exit out of Mushclient or the notepad it refuses to save. So I can't save over sessions. Any solutions? |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 13 Mar 2003 09:57 PM (UTC) |
Message
| What do you mean "it refuses to save"? In what way?
Judging by your code the problem is more that you would need to load it for the next session, otherwise each session would start with a blank notepad window.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Stratus
(25 posts) Bio
|
Date
| Reply #2 on Fri 14 Mar 2003 02:33 AM (UTC) |
Message
| Whenever I load the saved file and use the script again it either activates a seperate notepad or it clears the one I had already opened. I was wrong about it not saving, I thought it would save as a .txt file so when I looked for it in the folder I didn't see it. |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 14 Mar 2003 04:04 AM (UTC) |
Message
| The title has to be identical for it to use the same window.
What you might do on a world open (or world connect) which you can add a script for, is to use scripting to read the file into memory (there are examples on the forum), and then use world.appendtonotepad to put that data into the notepad window, ready for new events. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Stratus
(25 posts) Bio
|
Date
| Reply #4 on Sat 15 Mar 2003 03:27 PM (UTC) |
Message
| I changed the script to open "c:\program files\mushclient\poll" and now it actually brings up the same file which is an improvement but when I try to append to it it created a new notepad file
sub Connect (thename, theoutput, thewildcars)
open "C:\Program Files\Mushclient\Poll"
world.appendtonotepad "Poll", "Poll: Intro VS. Naveah!"
world.appendtonotepad "Poll", vbcrlf
end sub |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sat 15 Mar 2003 11:03 PM (UTC) |
Message
| I mean, you have to read the file into memory, and append it to your notepad. See this post:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1297
There is an example sub there "GetFileContents" - use that to get the file into memory, and then append it to the notepad (with world.AppendToNotepad) - then the earlier file will definitely be in the same notepad. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Stratus
(25 posts) Bio
|
Date
| Reply #6 on Sun 16 Mar 2003 06:29 AM (UTC) |
Message
| If I did that wouldn't I have to save everything in the notepad back into the file so the next time I opened Mushclient and the file it would read and copy everything back into the notepad again? |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | Top |
|
Posted by
| Stratus
(25 posts) Bio
|
Date
| Reply #7 on Sun 16 Mar 2003 06:55 PM (UTC) |
Message
| Isn't there any way I could just directly append it to the file instead of even using a seperate notepad? |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | Top |
|
Posted by
| Nick Gammon
Australia (23,162 posts) Bio
Forum Administrator |
Date
| Reply #8 on Mon 17 Mar 2003 12:12 AM (UTC) |
Message
| For storing ad-hoc results like this you might be better off using a database anyway. Look in the plugins section of this forum, there is an example database I did. A little modification of this, and you could store each vote into an Access database. That would be better in the long run than getting a file that is longer and longer. Also, you wouldn't lose votes in the event of a program or Windows crash. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
27,046 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top