mr-es335 Posted September 9, 2024 Posted September 9, 2024 Good day, In my understanding, a "Function" should perform a single operation. Multiple Functions can be "pieced together" to perform larger tasks. For example: One separate function Func _GeFirstString() "Hello" End Func ========================================================== A second separate function Func _GetSecondString() "World" End Func ========================================================== A combined function _OutputBothStrings...which consists of... ; --------------------------- _GeFirstString() _GetSecondString() ; --------------------------- Func _CombinedMe _GeFirstString() & _GetSecondString() = _CombinedStrings End Func ; --------------------------- Question 2a: What is the "combined" function referred to as? ...or... Question 2b: What do you call a group of functions placed "...one-after-the-other..." in a single script? Any assistance in this matter would be greatly appreciated! Thank you for your time...appreciated! mr-es335 Sentinel Music Studios
AndrewG Posted September 9, 2024 Posted September 9, 2024 Hello Mr-es335, Here is a good explanation: "Functions are "self contained" modules of code that accomplish a specific task. Functions usually "take in" data, process it, and "return" a result. Once a function is written, it can be used over and over and over again. Functions can be "called" from the inside of other functions." https://users.cs.utah.edu/~germain/PPS/Topics/functions.html The examples you provided to demonstrate your question, multiple functions are not necessary in this case. It is perfectly acceptable to write one function to perform the task of joining two strings together. Func _HelloWorld() Local $sStringOne = "Hello" Local $sStringTwo = "World" Local $sCombine = $sStringOne & $sStringTwo Return $sCombine EndFunc Global $sHelloWorld = _HelloWorld() ConsoleWrite(@CRLF & "!> " & $sHelloWorld & @CRLF & @CRLF) Question 2a: What is the "combined" function referred to as? Combining or the joining of two or more strings is referred to as concatenation. Question 2b: What do you call a group of functions placed "...one-after-the-other..." in a single script? A group of functions. A library. A program. I don't think there is a specific name for what you are asking about here.
Moderators Melba23 Posted September 9, 2024 Moderators Posted September 9, 2024 mr-es335, I would also say that a function is a block of code intended to be used several times within the same script - if it to be used just the once then there would be be little point in creating one as you might as well add the relevant lines in the main script where required. The exception would be if you were writing a library - such as the standard include files that come with AutoIt - which are designed to offer simplicity of use to the user by allowing complicated functions to be called by a one-line command from another script. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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