forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


advice needed on string loading/editing speed

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
rinus
Newbie


Joined: 02 Feb 2005
Posts: 2
Location: Netherlands

PostPosted: Thu Feb 03, 2005 12:33 am    Post subject: advice needed on string loading/editing speed Reply with quote

Hi there,

I made a program that reads message lines from gameserver logfiles, and removes color codes from the names. First (most important) problem is that due to the logfile sizes the process takes a while. I already added a progress bar for some animation, but i was wondering if there's faster ways than mine. Here's my code:

Code:

#create lists
  LIST CREATE,1
  LIST LOADFILE,1,%%LOG
  LIST CREATE,2

#variables
  %%ITEMS = @COUNT(1)
  %%TELLER = 1

#extract message lines
  WHILE @MATCH(1,"say: ")
    %%ITEM = @ITEM(1)
    REPEAT
      %%POS = @POS(^,%%ITEM)
      %%LEN = @SUCC(%%POS)
      %%ITEM = @STRDEL(%%ITEM,%%POS,%%LEN)
    UNTIL @EQUAL(%%POS,0)
    %%ITEM = @STRINS(%%TELLER"      ",7,@SUBSTR(%%ITEM,13,150))
    LIST ADD,2,%%ITEM
    %%TELLER = @SUCC(%%TELLER)
    %%ITEM = @NEXT(1)
  WEND
  LIST CLOSE,1
  LIST SAVEFILE,2,@PATH(%%LOG)@NAME(%%LOG)".messages.log"
  LIST CLOSE,2


Basically it creates two lists, loads the contents of the logfile in list 1 and the desired output in list 2, then saves list 2 to a file.

In list 1 it searches for lines containing "say: ", which are the message lines in the logfile. Next it searches for color codes (character ^ plus any letter,number or symbol, eg. "^7"), and removes them if found. when there are no more color codes it gets added to list 2.

Second problem is that when the program is doin its job no buttons can be clicked, i tried to put another IF statement inside the while loop but i dont think thats gonna help speed up things one bit... Here's what i tried:


Code:

%%EVENT = @EVENT()
IF @EQUAL(%%EVENT,BITMAP1CLICK)
  SHELL OPEN,"https://www........com"
ELSIF @EQUAL(%%EVENT,BITMAP2CLICK)
  SHELL OPEN,"mailto:rinus@orginizedcrime.com"
ELSIF @EQUAL(%%EVENT,BITMAP3CLICK)
  SHELL OPEN,"http://www.orginizedcrime.com/"
ELSIF @EQUAL(%%EVENT,BUTTON3BUTTON)
  IF @EQUAL(@ASK("Are you sure you want to exit?     "),1)
    EXIT
  END
END


Or should i try something like

Code:

IF @EVENT()

  .....

END


One last thing, i seen this "string.dll", would that be faster that what i got right now? I think it's got all the things i wanna use, but also alot of functions i dont need..

Help would be greatly appreciated, thx in advance.

______________
Rinus
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 03, 2005 9:20 am    Post subject: Reply with quote

String.DLL will easily outperform VDS in any such type of string operation. It will also do the most common file
operation directly in files, and much faster than even loading the file into a VDS list (big files in VDS lists
are quite slow loading...)

BTW. VDS is not threaded so as long as your program is doing one operation, it will not proceed
handling button clicks etc. until that process has finished.

Greetz
Dr. Dread

PS: If ya don't need the other DLL functions - don't us'em Laughing

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
rinus
Newbie


Joined: 02 Feb 2005
Posts: 2
Location: Netherlands

PostPosted: Thu Feb 03, 2005 1:28 pm    Post subject: Reply with quote

Thanks man, i figured there had to be a faster way of doing this, the loading takes a while indeed. My worst concerns however are the operations in the while loop, these were taking ages to complete lol. I'll test this string.dll right away, i'll let u know what speed improvements i come up with.


The second snippet i posted actually worked, only thing is that it had to check for events every time going thru te while loop... Maybe it's faster of testing IF a button was clicked, instead of testing WHICH button was clicked (if no button is clicked it will pass out of the if statement without evaluating the remaining conditions).

Anyways, thanks again for the advice!

______________
Rinus
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group