The Daily Click ::. Forums ::. Klik Coding Help ::. Converting string of letters into numbers?
 

Post Reply  Post Oekaki 
 

Posted By Message

Strife

Administrator
Der Dairy Crick

Registered
  21/11/2002
Points
  2305

VIP MemberGOTW AWARD! -Astro Dude - part 1 GOTM JULY - 2009 - 3RD PLACE!It's-a me, Mario!Has Donated, Thank You!I donated an open source project
2nd May, 2010 at 17:40:41 -

Is there a way to convert a string of letters into a number, and vice versa? I'm storing my game's data with a number array, which unfortunately doesn't allow for string entries, so I'd like to know if it's possible to manipulate numbers in a way so that I can store small bits of text, such as a name.

I tried using the Convert String to Number function that's built into MMF, but that only works for numbers, not letters. Is there a method I could use to represent each letter of the alphabet as a number and scrunch them together in the same variable, or will I have to dedicate an entire row of my array to storing letters individually (i.e. 1 = A, 2 = B, etc)?

 

aphant



Registered
  18/05/2008
Points
  1242
2nd May, 2010 at 18:13:48 -

Simply put, no.

It is possible, it would just be a very large number for a short, simple string. Your other alternative is to either dedicate a row as you mentioned, or you could try using another array type that takes numbers and strings.

 

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
2nd May, 2010 at 22:00:10 -

String arrays are much better to use, since u can easily store numbers as strings and retrieve them back. You might want to consider changing your array type.

 
Code me a sausage!

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
2nd May, 2010 at 22:26:27 -

Either use a string array or a row structure and the formatted object can convert char to the ascii number. Using an array of stings would be easier though .


 
n/a

Xgoff



Registered
  22/02/2009
Points
  135
3rd May, 2010 at 02:02:36 -

a string IS a number so yes

i don't remember if mmf has functions for converting characters to ascii values (which for letters begin at 65), but if it does then you can just run through a character at a time and convert them that way

 
Image

Strife

Administrator
Der Dairy Crick

Registered
  21/11/2002
Points
  2305

VIP MemberGOTW AWARD! -Astro Dude - part 1 GOTM JULY - 2009 - 3RD PLACE!It's-a me, Mario!Has Donated, Thank You!I donated an open source project
3rd May, 2010 at 08:52:11 -

Yeah, I probably should have stuck with a string array, but unfortunately, that would require me going back through all of my events (and we're talking three years worth of events ) and adding Val() tags wherever I refer to a value. So, with this in mind, using a row in my array is probably the best way to go at this point.

Thank guys.

 

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
3rd May, 2010 at 12:00:22 -

If you've already spent 3 years on it, what's another half hour?
Just go with a string array.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click