Jump to content

String format


vickerps
 Share

Recommended Posts

Hi Guys

I am having problems with the format of a number. I want to do a look up a ini which has info such as

[Number]

001=y

002=n

....

056=y

..

360=n

etc

Basically i want autoit to look up the value in a loop. However the FOR statment go up like 1,2,3,4 where want it to go up like 001,002,003, etc

here what i've wrote

For $No = 001 to 768    $Info = IniRead ( "No.INI", "Number", "$No", "NOEXIST" )    Msgbox(0,0,$No) Msgbox(0,0,$Info)       Next


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


techguy86
            
            
                Posted 
                
            
        
    
    
        


techguy86
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 73
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            Hi GuysI am having problems with the format of a number. I want to do a look up a ini which has info such as [Number]001=y002=n....056=y..360=netcBasically i want autoit to look up the value in a loop. However the FOR statment go up like 1,2,3,4 where want it to go up like 001,002,003, etchere what i've wrote

For $No = 001 to 768

$Info = IniRead ( "No.INI", "Number", "$No", "NOEXIST" )

Msgbox(0,0,$No)

Msgbox(0,0,$Info)

Next

[post="40760"]<{POST_SNAPBACK}>[/post]

Why not 1 instead of 001?

My Programs:Dissolve (Updated 5-30-06)Credit Card Validator (Not created as of yet)Master Lock Combination Cracker (Updated 7-08-07)Go Site-Seeing:My Website: - Click Here

Link to comment
Share on other sites

Entrys are read as strings, so just fill it up with zeroes...

For $No = 1 to 768

$No_str = $No
While StringLen($No_Str)<4 
   $No_str = "0" & $No_str
WEnd
$Info = IniRead ( "No.INI", "Number", "$No", "NOEXIST" )
Msgbox(0,0,$No)
Msgbox(0,0,$Info)

Next

cu

Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
Share on other sites

There is a StringFormat function which I can't give help you with.

But I can help you another way.

For $No = 1 to 768
   If $No < 10 Then
      $No = "00" & $No
   ElseIf $No < 100 Then
      $No = "0" & $No
   EndIf
   
   $Info = IniRead ( "No.INI", "Number", $No, "NOEXIST")
   Msgbox(0,0,$No)
   Msgbox(0,0,$Info)

Next
Link to comment
Share on other sites

  • Developers

Basically i want autoit to look up the value in a loop. However the FOR statment go up like 1,2,3,4 where want it to go up like 001,002,003, etc

<{POST_SNAPBACK}>

For $No = 001 To 768
   $Info = IniRead("No.INI", "Number", StringFormat("%03i", $No), "NOEXIST")
   Msgbox(0,0,$No)
   Msgbox(0,0,$Info)
Next

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.
  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...