Sign in to follow this  
Followers 0
pjw73nh

NooB needs help w simple file

5 posts in this topic

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


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                        





(adsbygoogle = window.adsbygoogle || []).push({});




                    
                
                    
                    
                    






    
    
        
Danny35d   

    
        
    
             8
    
        
    

        
            
                Universalist
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             8
    
        
    

                789 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #2 · 
            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
  


        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
CyberSlug   

    
        
    
             3
    
        
    

        
            
                Overwhelmed with work....
            
            

            
                

    
        
    

            
            MVPs
            
                
            
            
                

    
        
    
             3
    
        
    

                3,444 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #3 · 
            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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0