PerryRaptor Posted February 13, 2006 Posted February 13, 2006 I've been torturing StringFormat() trying to come up with a way to make variables that have fewer than 25 characters pad spaces to the right. I need to have the variables 25 charaters in length before moving on to the next procedure. Other ideas are welcome... 201.201.201.201 ; is less than 25 characters www.autoitscript.com/forum/index.php ; is more than 25 characters; 11 too many So that it will look like this if called via MsgBox Print >>>201.201.201.201 <<< or this, >>>www.autoitscript.com/foru<<<
Developers Jos Posted February 13, 2006 Developers Posted February 13, 2006 (edited) I've been torturing StringFormat() trying to come up with a way to make variables that have fewer than 25 characters pad spaces to the right. I need to have the variables 25 charaters in length before moving on to the next procedure. Other ideas are welcome... 201.201.201.201 ; is less than 25 characters www.autoitscript.com/forum/index.php ; is more than 25 characters; 11 too many So that it will look like this if called via MsgBox Print >>>201.201.201.201 <<< or this, >>>www.autoitscript.com/foru<<< I would do it this way: $YourVar = StringLeft($YourVar & " ",25) Edited February 13, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
GaryFrost Posted February 13, 2006 Posted February 13, 2006 $s_text = "201.201.201.201.11111111111122222222" $s_text = StringFormat(">>>>%-25s<<<<",StringLeft($s_text,25)) MsgBox(0,"test",$s_text) $s_text = "201.201.201.201" $s_text = StringFormat(">>>>%-25s<<<<",StringLeft($s_text,25)) MsgBox(0,"test",$s_text) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
PerryRaptor Posted February 13, 2006 Author Posted February 13, 2006 (edited) the helpfile for StringFormat() wasn't making any sense to me...thanks folks! This idea worked the best: ;Shorten the variable when too long $s_text = "201.201.201.201.11111111111122222222" $s_text = StringFormat(">>>>%-25s<<<<",StringLeft($s_text,25)) MsgBox(0,"test",$s_text) ;Lengthen the variable when too short $s_text = "201.201.201.201" $s_text = StringFormat(">>>>%-25s<<<<",StringLeft($s_text,25)) MsgBox(0,"test",$s_text) Edited February 14, 2006 by PerryRaptor
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now