The Daily Click ::. Forums ::. Klik Coding Help ::. Parsing a string character by character
 

Post Reply  Post Oekaki 
 

Posted By Message

Dysposin



Registered
  15/07/2007
Points
  6
20th June, 2010 at 17:07:07 -

I'm currently working on a project, in which I have to go through a string a character by character (ie. if the string is "qwerty", I could for example make an array where I have "q", "w", "e", "r", "t" and "y"). I've been looking through all the string modifying/manipulation add-ons I've found but none of them seems to support this. I came by String Manipulator( http://www.clickteam.info/extensions/extview.php?id=28 ), which seems to do the trick but I think it's for the MMF1, and the download is not working.

So, is there any way to do this, or is this a lost cause?

 
n/a

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
20th June, 2010 at 17:31:07 -

use the String Parser 2 Object: http://ext.neatwares.ath.cx/ext/String_Parser_2

At the start of the frame add a delimiter that will break up the text. Probably something that isn't used often like "%". Then when you write out the string write the delimiter between each section that you want to be broken up.

"Q%W%E%R%T%Y"

Then you can use the Get Element feature and choose the specific section of text you want by number. So 1 would be Q, 2 would be W, and so forth. If its an application that checks a user's text, you can have a hidden string copy what they are typing but add the delimiter between each letter and then use a loop to check it.

Edited by Sumo148

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
20th June, 2010 at 17:34:05 -

You don't need an extension.

+ Whenever...
-> Start fastloop "Parse", Len( >your string< )

+ On Loop "Parse"
-> Write: Mid$( >your string< , LoopIndex( "Parse" ), 1) to array position: LoopIndex( "Parse" )

(don't forget to untick the array's "Base 1 Index" option, to make it 0-based instead).

Edited by Sketchy

 
n/a

Dysposin



Registered
  15/07/2007
Points
  6
20th June, 2010 at 18:14:55 -

Sumo148, I'm aware of that method and I've used it even in this project. However the problem is that I cannot use delimiters in this (I'm using this to read a level data, and the format doesn't allow them).

Sketchy, that's exactly what I was looking for. To make things even easier, the string will have a constant length. Thanks, I'll try this.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click