Jump to content

Addition of two variables


Go to solution Solved by Jos,

Recommended Posts

  • Developers
  • Solution

It this piece of code supposed to be AutoIt3 syntax?   Don't think so, just open the helpfile and check the proper syntax. ;) 

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

(Edited to reflect the correction below pointed out by Melba23)

In AutoIt, if you want to concatenate two variables without performing arithmetic addition, you can simply use the "&" operator. Here's how you can do it:

; Define variables
Local $var1 = 1
Local $var2 = 2

; Concatenate variables
Local $var3 = $var1 & $var2

; Display the concatenated value
MsgBox(0, "Concatenated Result", $var3)

Here's a simplified version:

Local $var1 = 1, $var2 = 2
Local $var3 = $var1 & $var2
MsgBox(0, "Concatenated Result", $var3)

Here's the most concise version:

Local $var3 = "1" & "2"
MsgBox(0, "Concatenated Result", $var3)

In the AutoIt help file, the concept of concatenation may not be explicitly listed under a specific section with that term. However, the functionality of concatenation is often explained in various sections that cover string manipulation or operations involving strings.

Here's where you can find information related to concatenation in the AutoIt help file:

  1. String Handling Functions: The AutoIt help file contains a section dedicated to string handling functions. Functions like StringConcatenate, StringFormat, StringRegExpReplace, and others involve string manipulation, which indirectly covers concatenation.

  2. Operators: The help file includes a section on operators where you can find information about the string concatenation operator (&). It explains how the & operator can be used to concatenate strings and concatenate variables with strings.

  3. Examples: The help file often includes examples demonstrating various operations, including string concatenation. These examples can be found throughout the documentation, particularly in sections related to string manipulation or variable usage.

While the term "concatenation" might not be explicitly listed, the functionality and usage of concatenating strings are covered in the contexts mentioned above within the AutoIt help file.

Edited by LAteNightSpecial
Link to comment
Share on other sites

  • Moderators

LAteNightSpecial,

Quote

Here's the code in AutoIt that combines two variables:

Er, no! If you read the OP, (s)he wants to concatenate the 2 variables - not perform arithmetic addition. The use of the "&" operator is entirely correct in this case.

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

 

Link to comment
Share on other sites

8 minutes ago, Melba23 said:

LAteNightSpecial,

Er, no! If you read the OP, (s)he wants to concatenate the 2 variables - not perform arithmetic addition. The use of the "&" operator is entirely correct in this case.

M23

You are absolutely correct Melba23! I misread the OP request. I edited my response to reflect the correct logic. Thanks! for pointing that out to me. 🤯

Link to comment
Share on other sites

  • Moderators

Don't forget you're turning it into a string at some of your examples.  While most functions will still work backwards it's safer to just cast it if you still need to use it as a number/int (eg.. Number("1" & "2.3") or Int("1" & "2") as an example).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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