Jump to content

Variable Assign - (Moved)


Recommended Posts

17 minutes ago, ashraful089 said:
Local $var1 = $var2 = $var 3 = 100

What is the correct declaration of this command in autoit, i am trying but value not being assigned into variables

Maybe something like this ? :

Local $var3 = 100, $var1 = $var3, $var2 = $var3
ConsoleWrite("Var1 = " & $var1 & @CRLF)
ConsoleWrite("Var2 = " & $var2 & @CRLF)
ConsoleWrite("Var3 = " & $var3 & @CRLF)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum.

Moderation Team

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

  • Melba23 changed the title to Variable Assign - (Moved)
  • Melba23 unlocked this topic

maybe i am uanble to represent the exact thing.

In normal, $var1=100, $var2=100, $var3=100 , .............. , $var40=100

Musashi comment is ok

Local $var3 = 100, $var1 = $var3, $var2 = $var3

but i am seeking for more short form if possible, like Var3 i will use once and other variable value will be assigned from var 3
 

Link to comment
Share on other sites

you are looking for array?

Local $mVar=100, $var=[$mVar+1,$mVar+2,$mVar+3,$mVar+4,$mVar+5]

ConsoleWrite("$mVar = " & $mVar & @CRLF)
ConsoleWrite("$var[0] = " & $var[0] & @CRLF)
ConsoleWrite("$var[1] = " & $var[1] & @CRLF)
ConsoleWrite("$var[2] = " & $var[2] & @CRLF)
ConsoleWrite("$var[3] = " & $var[3] & @CRLF)
ConsoleWrite("$var[4] = " & $var[4] & @CRLF)

#cs
;~   or
    #include <Array.au3>
    Local $mVar=100, $var[0]
    For $x = 1 To 40
       _ArrayAdd($var, $mVar + $x)
    Next
    _ArrayDisplay($var)
#ce

 

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

@bogQ in my realization your code will have the same variable name "var" but in my work i like to keep variable name different. so i think i cant use array. pardon me, maybe i should mention variable name difference.

In this case what can be,

in language c, $Mango = $Apple = $Jackfruit = ...... = $Banana =100
means all variable value is 100
A = B = C = D = E = F = 100 means variable A, B, C, D, E, F all's value is 100
in Autoit any declaration like that

Local $Mango=100, $Apple=100, $Jackfruit=100 , .............. , $Banana=100
 
Link to comment
Share on other sites

readability of code should always take priority than code minimality, aldo i really don't like to use Assign or Eval, you can add var names to array and use Werty code to set their value directly from array or var names

edit with example:

AutoIt3Wrapper_Run_AU3Check needed to allow to run due to undeclared warning

#AutoIt3Wrapper_Run_AU3Check=N
#include <AutoItConstants.au3>

Local $var = 100, $varnames=["var1","var2","var3"]
For $x = 0 To UBound($varnames) - 1
    Assign($varnames[$x], $var, $ASSIGN_FORCELOCAL)
Next
ConsoleWrite("var1 = " & $var1 & @CRLF)
ConsoleWrite("var2 = " & $var2 & @CRLF)
ConsoleWrite("var3 = " & $var3 & @CRLF)

#cs
;~   or
    Local $var = 100, $varnames=["var1","var2","var3","var4","var5","var6","var7","var8","var9","var10"]
    For $x = 0 To UBound($varnames)-1
        Assign($varnames[$x], $var, $ASSIGN_FORCELOCAL)
        ConsoleWrite($varnames[$x]&" = " & Eval($varnames[$x]) & @CRLF)
    Next
#ce

 

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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