|
-
Jul 19th, 2000, 08:13 AM
#1
Thread Starter
Addicted Member
Hello!
I need a string compression algorithm, and I can't find one anywhere.
Actually, I found this one:
http://www.planetsourcecode.com/vb/s...&txtCodeId=467
But it doesn't work (the dictionary is the wrong size).
Plus, I'm looking for a little bit stronger compression if possible (but not neccesary).
I also found this one:
http://www.planetsourcecode.com/vb/s...txtCodeId=2075
But, it does not work for me, because I need to compress/encrypt strings like:
"Hey everyone, my name is Marcus. How is everyone?"
and that last one makes my string even longer.
(It's for a chat program, client/server). Help?
(If anyone could get the first one working, that might be good!)
Thanks!
-
Jul 19th, 2000, 09:09 AM
#2
Fanatic Member
Raydr,
Not a problem to fix that code.
Code:
'change the following
If Len(Dict$) <> 320 Then 'just To check...
MsgBox "PACKING ERROR: Dictionary is the wrong size"
Exit Function
End If
'to this
'He seems to have got the length of his own string wrong.
If Len(Dict$) <> 312 Then 'just To check...
MsgBox "PACKING ERROR: Dictionary is the wrong size"
Exit Function
End If
Iain, thats with an i by the way!
-
Jul 19th, 2000, 09:38 AM
#3
Thread Starter
Addicted Member
I probably looked like a dummy.
I'm not familiar with compression/encryption routines, so I'm iffy about modifying them. However, I did apply your change, and found OTHER bugs in this code.
I wonder if this code was even tested before it was put out there? It stops when it encounters a space also.
Perhaps someone could point me to a better compression function??
-
Jul 19th, 2000, 10:14 AM
#4
Fanatic Member
You are right, that code has been badly tested. I have changed it so it works. Any more problems let me know.
Seeing as i would be breaching copyright, i can't post it here. Change the following.
Code:
If cnt = Len(text$) Then'if the End of the String has been reached
text$ = Chr$(255) + temp$ + Chr$(Asc(Mid$(text$, cnt, 1)) - 32)
Exit Function '^^^^ add the last character
End If
'change it to this. The guy had forgot to return the value.
If cnt = Len(text$) Then 'if the End of the String has been reached
text$ = Chr$(255) + temp$ + Chr$(Asc(Mid$(text$, cnt, 1)) - 32)
PackTxt = text$
Exit Function '^^^^ add the last character
End If
Iain, thats with an i by the way!
-
Jul 19th, 2000, 10:17 AM
#5
Thread Starter
Addicted Member
I had already fixed that part.
But try compressing and uncompressing this:
"This is a test"
"My name is Marcus".
I think you'll see what the problem is.
I think I just want a new function.
-
Jul 19th, 2000, 10:29 AM
#6
Fanatic Member
Not a problem. Those strings work fine.
This is my guess at why it is not working for you.
You are using TextBoxes to hold the strings, aren't you? If so, this is why it does not work. The textbox will not display an awful lot of the ascii character set.
If you use string variables to hold the strgins, you should not have a problem.
Iain, thats with an i by the way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|