Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch Ssript String Formating
Name: fsloke Date: July 4, 2009 at 08:00:58 Pacific OS: Windows XP Subcategory: Batch
Comment:
Hi All,
Here some Question regarding String. Question1 How to formula a integer to a 5 digit value 1 to 00001 2 to 00002 ..... 10 to 00010
Question 2 How to get a substring of a String? Example: set word =aeroplane The value I want to get from "aeroplane" is "ro"
set int=12
set Fint=%int%
if %int% lss 10 set Fint=0%Fint%
if %int% lss 100 set Fint=0%Fint%
if %int% lss 1000 set Fint=0%Fint%
if %int% lss 10000 set Fint=0%Fint%
echo.Formatted %int% is %Fint%
Beware never perform arithmetic comparisons or operations with numbes with leading zeroes as they are interpreted as octals. Use formatted numbers for display only.
Question 2:
set mystring=aeroplane
echo.substring is %mystring:~2,2%
The general rule is %var:~m,n%
where m is the position of the substring starting from zero and n its lenght. Both m and n may assume negative value or be omitted. Type Set /? to know more.
0
Response Number 2
Name: ghostdog Date: July 4, 2009 at 09:34:29 Pacific
Reply:
@OP if its not for homework, you can use vbscript. see here for example for question 1 on padding with zeroes Qns 2: you can use Mid() function to get substring
Summary: This seems like a whitespace error, but I cant find the answer, note~ I need the path string format as described below for output to .txt file... Format of path string 'stored' in %profileE% "C:\Use...
Summary: Can anyone give me any information on any classes for string formatting. When I say string formatting i mean justifying and fill width,etc. ...
Summary: Ok, I'm currently programming a simple frontend type program that requires the user to input heir telephone number. Because its easier I stored the variable fone as a string. What I need to know (for ...