• Welcome to Valhalla Legends Archive.
 

Reading a list

Started by Gangz, December 05, 2003, 01:41 AM

Previous topic - Next topic

Gangz

I am making an access list for my bot and i am puttin masters in Master.txt and operator in Op.txt and so on. I was wondering if i have a cmd look like
Case "IPB"
                   If upperusername = UCase(Form1.varmaster) Then Form1.Send "/ban " & Right(Message, (Len(Message) - 5))
                   If upperusername = UCase(Form1.varmaster) Then Form1.Send "/Ignore " & Right(Message, (Len(Message) - 5))

How can i make a it check a list of names from a txt and return a match as varmaster?

Smurfling

#1
Well i would suggest you to read the textfile into an array. Then perform a check if the username is within the array.

I solved that for me through loading all data from a XML file into a SortedList. It's pretty easy to check if the username is in there (SortedList.ContainsKey(Username)). You can store much more information than just the username within the sortedlist (Values). Once you know the username is there, just get the index and the values. Pretty easy though.

Answer for your question would be so:

If SortedList.ContainsKey(Username) Then
   Select Case CMD
         Case cmdBan
             Insert(Type.tNTString,"/ban " & cmdVar1 & " " & cmdVar2)
             SendPacket(&HE)
   End Select
End If


You can replace the code within the if statement with your own code ;)

Fleet-

I used listboxes to store all the data which wouldnt be shifted around alot.

ie: Tagbans, Shitlist, Phrasebans, Access

Listboxes are fairly simple to read from as well. HOWEVER, they are not the best on speed, I may switch to variable arrays soon depending on how much the change impacts the ammount of memory my bot eats.

Also just as an idea...write a small send sub..and dont put it in form1 so you don't have to type "Form1.Send" every time.

Skywing

As a general practice, you should avoid using user-interface features for things completely unrelated to a user interface (e.g. as a data storage mechanism).

ObsidianWolf

I use an Access database for all my data besides channel logs, not entirely sure how efficient it is, but it saves time for me.  If you would like info on how to do this just pm me.

Zakath

Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Fleet-

I recently just switched from listboxes to arrays, arrays are a bit more pain in the ass, but they are alot faster and less memory consuming.

Puzzle

#7
Quote from: Fleet- on December 10, 2003, 07:30 AM
I recently just switched from listboxes to arrays, arrays are a bit more pain in the ass, but they are alot faster and less memory consuming.

I'm not exactly sure how much faster switching from objects to arrays would make the program, but I'm pretty sure it's not enough to be noticable. Like Skywing said, it just isn't a good practice to use objects for data storage.
Edit: Spelling