Jump to content
Sign in to follow this  
dabus

Melting variables into another.

Recommended Posts

dabus

Hi @ All,

I've got a little question (maybe I searched for the wrong words :idiot: ):

I would like to add 2 variables to a new one.

Example:

$Var1 = "Hello "

$Var2 = "world"

$Var3 should be "Hello world"

I have tried $Var3=($Var1&Var2) and other combinations but had no success.

:D

Any suggestions?

Thx in advance.

Share this post


Link to post
Share on other sites
SlimShady

$Var1 = "Hello "
$Var2 = "world"
$Var3 = $Var1 & $Var2

Share this post


Link to post
Share on other sites
MHz

As for what SlimShady has stated except for adding the space.

$Var3 = $Var1 & " " & $Var2

Share this post


Link to post
Share on other sites
dabus

Thx.

And how can I do this?

$Var1 = "Hello"

$Var2 = "world"

?????? = "True"

MsgBox (0, "" , $Helloworld )

... should show a window True.

So ??? (which "is" Helloworld") is meant to be a variable made out of variables.

I tried sth. like:

$($Var1&$Var2) = "True"

but it does not work.

Sorry, I can't explain it better. :idiot:

Would be if someone has a hint, since I could use more functions. :D

Edited by dabus

Share this post


Link to post
Share on other sites
Chris_1013

If you want to combine the contents of $Var1 and $Var2 to make the name of a new variable, then use the Assign function, like this;

$Var1 = "Hello"
$Var2 = "world"
Assign($Var1 & $Var2),"True")
MsgBox (0, "" , $Helloworld)

Share this post


Link to post
Share on other sites
dabus

What version do you use?

I don't see any asign-function in the help-file.

:idiot:

Share this post


Link to post
Share on other sites
sykes

As for what SlimShady has stated except for adding the space.

$Var3 = $Var1 & " " & $Var2

<{POST_SNAPBACK}>

Slim *did* add a space:

$Var1 = "Hello "

$Var2 = "world"

$Var3 = $Var1 & $Var2

Notice the space behind the Hello

We have enough youth. How about a fountain of SMART?

Share this post


Link to post
Share on other sites
MHz

Yes indeed, I did not see the space. Forgive me. :">

My previous post is incorrect.

@sykes

Thanks for clarifying.

Share this post


Link to post
Share on other sites
dabus

Hi, I'm working on a Zip-Gui.

But I could use a pint of help... :D

Here's my function so far:

Func ReadZip ()

$Line=0

$File=0

While 1

$Line=$Line+1

$Search = RegEnumVal ( $Key, $Line)

If $Search = "" Then ExitLoop

$AddFile = RegRead ( $Key , $Search )

If FileExists ( $AddFile ) Then

$Add=1

$File=$File+1

For $n=1 to $File Step 1

Assign( "TmpFile", "$AddFile"&$n, 1)

$SearchFile=$TmpFile

If StringInStr ( $SearchFile , $AddFile ) Then

$Add=0

MsgBox (0, "RunYes:"& $SearchFile , $AddFile )

Else

MsgBox (0, "RunNo:" & $SearchFile , $AddFile )

EndIf

Next

If $Add=1 Then

Assign ( "AddFile"&$n, $AddFile , 2)

MsgBox (0, "Add" , $AddFile )

EndIf

EndIf

WEnd

EndFunc

It searches for some entries in the registry, sees if they are valid and puts them into $AddFile1, $AddFile2 and so on. I also included some MsgBox stuff for debugging.

So far, so good. My problem is the bold part of the text: I want to search them. :D

But $Searchfile is not treated as a var (well, could have worked :) ), but as text. How can I force that? Or is there a better way to do that?

The script should do this

If StringInStr ( $AddFile1 , $AddFile ) Then ...

If StringInStr ( $AddFile2 , $AddFile ) Then ...

... you know what I mean? :huh:

Share this post


Link to post
Share on other sites
buzz44

You could use the latest BETA 3.1.1.7 with one of the new operators...

Operator: &=

Concatenation assignment. e.g. $var = "one", and then $var &= 10 ($var now equals "one10")

Edited by Burrup

qq

Share this post


Link to post
Share on other sites
dabus

Thx for your advice, I did used a counter and Stringsplit, not Assign.

It looks like this

While 1

...

$Counter=$Counter+1

$Dir=$Dir&"|"&$OutPut

WEnd

$Dir=StringReplace ( $Dir, "|", "", 1 )

$Dir=StringSplit( $Dir, "|")

For $n=1 to $Counter Step 1

MsgBox (0, "Dummy", $Dir[$n] )

Next

So many ways to solve a problem .... :)

Edited by dabus

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.