CCMgmt Posted April 12, 2011 Share Posted April 12, 2011 Hi All, I'm a newbie to AutoIt and writing a couple of scripts to get the feel of it and having an issue using "Func".In the script below at the line "If WinExists("AutoIt Help") Then Test()" the script goes to and executes "Func Test()" but instead of exiting,it returns to and runs the lines "MsgBox(0, "", "No Exit Again")" and"If @OSArch = "X86" Then StartTest_32()" then exits.Question: WHY?Any and all help appreciated.Thank YouOpt("WinTitleMatchMode", 2) Stat() Func Stat() MsgBox(0, "", "START") If WinExists("AutoIt Help") Then Test() MsgBox(0, "", "No Exit Again") If @OSArch = "X86" Then StartTest_32() If @OSArch = "X64" Then StartTest_64() EndFunc exit Func Starttest_32() MsgBox(0, "", "Starttest_32") EndFunc Func Starttest_64() MsgBox(0, "", "Starttest_64") EndFunc Func Test() MsgBox(0, "", "END") EndFunc Exit Link to comment Share on other sites More sharing options...
KaFu Posted April 12, 2011 Share Posted April 12, 2011 (edited) The exit call is placed outside the function Func Test() MsgBox(0, "", "END") EndFunc Exitshould be: Func Test() MsgBox(0, "", "END") Exit EndFunc Edited April 12, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
CCMgmt Posted April 12, 2011 Author Share Posted April 12, 2011 The exit call is placed outside the function Func Test() MsgBox(0, "", "END") EndFunc Exitshould be: Func Test() MsgBox(0, "", "END") Exit EndFunc Ok, so then I should create a Func _End() ;Exit Script Exit EndFunc OR Next_Step() ;Goto next step and not return to previous function? Link to comment Share on other sites More sharing options...
nitekram Posted April 12, 2011 Share Posted April 12, 2011 When calling a function, after the function finishes it returns to the next line after the call to the function. So say you call a function from the top of your code" functionttest() ; after this completes the next line will be processed msgbox('','msgbox', 'next line of code') 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
CCMgmt Posted April 12, 2011 Author Share Posted April 12, 2011 Ok then What is the Purpose of "CALL"? Link to comment Share on other sites More sharing options...
CCMgmt Posted April 12, 2011 Author Share Posted April 12, 2011 Ok then What is the Purpose of "CALL"? if not to call a function and then return to the call point? Link to comment Share on other sites More sharing options...
kaotkbliss Posted April 12, 2011 Share Posted April 12, 2011 if it returned to the same line it came from (the call to the func) then you would have a never-ending loop between the func and the call to the func. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
BrewManNH Posted April 12, 2011 Share Posted April 12, 2011 There is no point to using Call rather than just calling the function by name except if you want to conditionally jump to a function by using a variable. Which to me seems still rather pointless as you could do it with a Switch/Select/If statement just as easily. Also, you can't pass values using ByRef with the Call function. I'm sure it has its uses but I haven't run into one yet. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
CCMgmt Posted April 13, 2011 Author Share Posted April 13, 2011 Thank You Everyone for your help. I see the light at the end of the tunnel. Link to comment Share on other sites More sharing options...
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