ashraful089 Posted June 20, 2023 Share Posted June 20, 2023 (edited) 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 Edited June 20, 2023 by Melba23 Link to comment Share on other sites More sharing options...
Musashi Posted June 20, 2023 Share Posted June 20, 2023 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) ashraful089 1 "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 More sharing options...
ashraful089 Posted June 20, 2023 Author Share Posted June 20, 2023 is not it possible to declare at a time? like a-=b=c=d=e=f... = value, i am asking cause sometimes i needed to assign in 30-40 variable. if any possible way to it in a line would be helpful. Thanks in advance Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 20, 2023 Moderators Share Posted June 20, 2023 Moved to the appropriate forum. Moderation Team 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 Link to comment Share on other sites More sharing options...
Werty Posted June 20, 2023 Share Posted June 20, 2023 For $loop = 1 To 40 Assign("var" & $loop, 100) Next Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
ashraful089 Posted June 20, 2023 Author Share Posted June 20, 2023 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 More sharing options...
bogQ Posted June 20, 2023 Share Posted June 20, 2023 (edited) 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 June 20, 2023 by bogQ ashraful089 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
ashraful089 Posted June 20, 2023 Author Share Posted June 20, 2023 @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 More sharing options...
bogQ Posted June 20, 2023 Share Posted June 20, 2023 (edited) 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 June 20, 2023 by bogQ ashraful089 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
ashraful089 Posted June 21, 2023 Author Share Posted June 21, 2023 i will check this prother 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