AutoHotkey Community

It is currently May 26th, 2012, 6:36 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: March 8th, 2008, 4:25 am 
Offline

Joined: October 30th, 2007, 1:40 pm
Posts: 20
I'm having problems elminating commas from a text input string.

The input variable value is txtVar1 = 1,234. How can this string
be modified so that the variable txtVar1 will contain the value 1234


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2008, 5:20 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Code:
var=1,234
StringReplace, var, var, `,,, UseErrorLevel
MsgBox, %var% `n %ErrorLevel% commas were replaced.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2008, 9:06 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
Code:
String = the national debt ~= 9,400,000,000.00, and all americans have to pay it, eventually (1 , 2).
Loop, parse, String
{
   If (A_LoopField + 1)
      InANumber = yes
   If (A_LoopField = "," && InANumber = "yes")
      continue
   If !(A_LoopField + 1)
      InANumber = no
   NewString .= A_LoopField
}
msgbox %NewString%
Removes all commas that appear immediately after a nunmberal. plz forgive my coding as I am drunk ATM.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2008, 11:44 am 
Offline

Joined: February 18th, 2008, 8:26 pm
Posts: 442
As jaco0646 demonstrated StringReplace can be used for this...

Code:
txtVar1 = 1,234
StringReplace, txtVar1, txtVar1, `,, , All

MsgBox, %txtVar1%


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, kkkddd1, Tipsy3000, Yahoo [Bot] and 78 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group