Sign in to follow this  
Followers 0
borutc

name of a variable

8 posts in this topic

Hello. Okay this might be a stupid question but here it goes.

I've got 2 strings, lets say "x" and "1". Can i somehow combine these 2 strings into a variable called $x1?

Thank you

Share this post


Link to post
Share on other sites



borutc,

Your variables need to begin with a $ and if they are strings, you use the concatenation operator & to join them:

$x = "Hello "
$1 = "world!"

$x1 = $x & $1

MsgBox(0, "Joined", $x1)

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

borutc,

Your variables need to begin with a $ and if they are strings, you use the concatenation operator & to join them:

$x = "Hello "
$1 = "world!"

$x1 = $x & $1

MsgBox(0, "Joined", $x1)

All clear? :)

M23

Okay maybe i didnt ask right :) But its like this:

lets say we have

$something = "x"

$somethingelse = "1"

i would like to make a variable caled $x1, which is combined with these 2 strings. is it even possible? :P

thank you

Share this post


Link to post
Share on other sites

borutc,

Please explain what you are trying to do.

You can create variables using strings like that, but there is nearly always an better way to do things. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

borutc,

Please explain what you are trying to do.

You can create variables using strings like that, but there is nearly always an better way to do things. :)

M23

Okay. I have some numbers stored in variables called $x1, $x2, etc. I want to make a loop from 1 to 10. In the loop there is a function that accepts a parameter. So the first time i want it to accept the variable $x1, the 2nd time $x2, etc. So i tought i could combine the number of the loop with "x" to tell it which paramter to accpet. Dont know if this makes any sense :)

Thank you

Share this post


Link to post
Share on other sites

borutc,

It does - and the answer is an array. :)

Store your parameter variables in the array as $aArray[1], $aArray[2], etc and then just use the loop counter to address the one you want on each pass.

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

borutc,

It does - and the answer is an array. :)

Store your parameter variables in the array as $aArray[1], $aArray[2], etc and then just use the loop counter to address the one you want on each pass.

All clear? :)

M23

All clear. Will do that. Thank you :P

Share this post


Link to post
Share on other sites

borutc,

When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read.

And a slightly belated welcome to the AutoIt forum. Glad we could help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0