Jump to content

NooB needs help w simple file


pjw73nh
 Share

Recommended Posts

I am trying to do the equivalent of a goto (batch) with AutoIt. When this runs on an XP machine, it runs the lower (function) then does the upper part. If I change it. Is there something wrong with my CALL or FUNCTION?

Tnx in advance.

Paul..

; Verifies if OS is Windows XP

If @OSversion = "WIN_XP" Then Call ("winxp")

RunWait(@COMSPEC & " /c Dir C:\windows")

msgbox(0,"results", " The non-windows XP portion ran fine ")

exit



;Runs the XP procedure.

Func winxp()

RunWait(@COMSPEC & " /c Dir C:\windows")

msgbox(0,"results", " The windows XP portion ran fine ")

EndFunc

EXIT







msgbox(0,"results", " If you see this the script didn't run well. ")


EXIT


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


Danny35d
            
            
                Posted 
                
            
        
    
    
        


Danny35d
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 809
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            When you want to used a function you don't need to use (CALL) you used just the name of the function()If @OSversion = "WIN_XP" Then winxp()


            
        

        

        
            

    
        

        
            
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
        
    

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


CyberSlug
            
            
                Posted 
                
            
        
    
    
        


CyberSlug
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                MVPs
                
                    
                
            
            
                
                    
                        
                            
                                
                            
                                 3.4k
                            
                                
                            
                        
                        
                    
                
            
            
                

    
    
        
Overwhelmed with work....
    
    

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                    (edited)
                
                
            
        
    

    

    

    
        
        
            ; code here runs

If @OSversion = "WIN_XP" Then
;any code here is only run if OS is Windows XP
Else
;any code here is only run if OS is NOT Windows XP
EndIf

;any code here runs in either case

Alternative

; code here runs

If @OSversion = "WIN_XP" Then
;any code here is only run if OS is Windows XP
    Exit
EndIf

;This code only runs if OS is NOT Windows XP since the above code calls Exit
MsgBox(4096,"","non-xp)
Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

When you want to used a function you don't need to use (CALL) you used just the name of the function()

If @OSversion = "WIN_XP" Then winxp()

Danny35d, (and all who replied) thanks for the info. I tried that before, but just to be sure I didn't fat-finger it, I just now tried it again.

If @OSversion = "WIN_XP" Then winxp()

It still runs the second portion and then the first portion, just like the original one. I will probably use one of the other suggested methods for now, but I would really like to know where I am going wrong.

Thanks again to all of you for your help. I really appreciate your patience.

; Verifies if OS is Windows XP

If @OSversion = "WIN_XP" Then winxp()

RunWait(@COMSPEC & " /c Dir C:\windows")

msgbox(0,"results", " The non-windows XP portion ran fine ")

exit



;Runs the XP procedure.

func winxp()

RunWait(@COMSPEC & " /c Dir C:\windows")

msgbox(0,"results", " The windows XP portion ran fine ")

endfunc

EXIT
Link to comment
Share on other sites

  • Developers

Danny35d, (and all who replied) thanks for the info. I tried that before, but just to be sure I didn't fat-finger it, I just now tried it again.

If @OSversion = "WIN_XP" Then winxp()

It still runs the second portion and then the first portion, just like the original one. I will probably use one of the other suggested methods for now, but I would really like to know where I am going wrong.

Sounds exactly what you have programmed. It will run the WINXP function after which it returns and runs the rest of the script. If you want only the WINXP function then you need something like:

If @OSversion = "WIN_XP" Then 
 winxp()
Else
 RunWait(@COMSPEC & " /c Dir C:\windows")
 MsgBox(0, "results", " The non-windows XP portion ran fine ")
EndIf

;Runs the XP procedure.
Func winxp()
 RunWait(@COMSPEC & " /c Dir C:\windows")
 MsgBox(0, "results", " The windows XP portion ran fine ")
EndFunc  ;==>winxp
Exit

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