VbScript Replace Function [SOLVED]

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

VbScript Replace Function [SOLVED]

Postby cpkspikyhair » Sat Apr 18, 2009 5:03 pm

Hey people! I'm working on an text-ASCII converter, and I have figured out most of the code on my own, but I am having some problems. For example, whenever I use the Len, Chr, and Mid functions to search for two-character clumps in the string and convert them, it is including ALL of the clumps, even the ones in the middle.

For example, let's say I need to convert this ASCII string into characters:

678075

In character form, it means "CPK". However, when I use my converter, it translates to:

CNP?K|

After toying with the converter, I realized something. The converter read the string differently than I wanted it to. Instead of reading "67,80,75", it read "67,78,80,07,75,5". I thought I could use the replace function to get rid of every other character in the string. Can someone help me achieve this?

Thanks in advance!
Last edited by cpkspikyhair on Sun Apr 19, 2009 7:46 pm, edited 1 time in total.
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby 3dgamer » Sat Apr 18, 2009 7:37 pm

Hi there cpkspikyhair,

I don't know much about ASCII conversion, but I went to another site that had an ASCII converter and tested your "678075" number without using spaces and it came back with a null result. But when I added the spaces in between the numbers, it converted fine. It also seemed to convert it fine when I used "CPK", converting it back into the "678075" number.

So it seems like if numbers are used, spaces have to be honored.

But that is purely my guess. :)

Well, hope you get your problem resolved soon.

P.S. - This the online converter I used for testing your number - http://www.cs.carleton.edu/faculty/adalal/teaching/f05/107/applets/ascii.html
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am

Postby ShadowHunter » Sat Apr 18, 2009 7:59 pm

Hi,

Quickly wrote a snipped for you, didn't test it though but it should get you started :D

Code: Select all
Sub Decode(ASCII)
Dim Lenght, TextString, Counter

Lenght = Len(ASCII)

   For k = 1 to Lenght Step 2
      TextString = TextString & Chr(Mid(ASCII,k,2))
   Next

MsgBox "The decoded text is: " & TextString

End Sub


With best regards,

ShAdOwHuNtEr
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby cpkspikyhair » Sun Apr 19, 2009 2:42 am

Thanks, ShAdOwHuNtEr. I'll test it tomorrow :D .

EDIT: Thank you so much! It worked!! :D

Also, I'd just like to point out that I used your trial & registration code as a reference for my converter, so thank you for your help!
PSPPC GameMaker!! Where you can find PSP and PC games up for download!
User avatar
cpkspikyhair
Games Page Administrator
 
Posts: 425
Joined: Thu Jun 28, 2007 1:49 pm
Location: On Mars (Yes There Is Water :) )

Postby ShadowHunter » Sun Apr 19, 2009 4:45 pm

Glad I could help :D
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests