Jump to content

Recommended Posts

Posted

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!

Posted

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
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
  • Recently Browsing   0 members

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