Jump to content
Sign in to follow this  
AoRaToS

How can I do this?

Recommended Posts

AoRaToS

This is rather easy I believe, let's say I have this script

$x = 3

Msgbox(0,"",$x)

This will show 3, but what If I want it to show $x instead, but not by including "$x", is there a way to indicate whether it will show the variable rather than the value it holds?

I think in C++ when you use a & you get that...

PS Is it called "call by reference"?And the other is by value?

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
GrungeRocker

Using & in C++ will show the address in memory of your var


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites
GrungeRocker

Yes you're right about that :)

What about what I want to do?

"$x" :-D

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites
Zinthose

Sorry but there is no way of acquiring the variable name, at least that I can see.

But I did throw this together. It's not what you asked for but might be but you need.

ConsoleWrite(_CodeLine(@ScriptLineNumber) & @CRLF); This Line will be Printed to the command line

Func _CodeLine($ScriptLine)
    Local $Start, $End
    
    If @Compiled Then Return SetError(1, 0, "Compiled Script: Can not return Script line")
    
    Local $File = FileOpen(@ScriptFullPath, 0)
    Local $Data = FileRead($File)
    FileClose($File)
    
    If $ScriptLine = 1 Then
        $Start = 1
    Else
        $Start = StringInStr($Data, @CRLF, 1, $ScriptLine - 1) + 2
    EndIf
    
    $End = StringInStr($Data, @CRLF, 1, 1, $Start)
    If $End = 0 Then Return StringMid($Data, $Start)
    
    Return StringMid($Data, $Start, $End - $Start)
EndFunc

edit: fixed issues with calling from first and last lines of script.

Edited by Zinthose

--- TTFN

Share this post


Link to post
Share on other sites
AoRaToS

I can't use that :)

I have a script but it's growing quite large cause I have to repeat stuff with slight differences, it would be easier if I could get a variable name and somehow change it so that the one function I have can work every time.

I have 10 tabs to do the same thing with different variables like

func 1

msgbox x1

msgbox x98

msgbox x54

endfunc

func 2

msgbox x9

msgbox x3

msgbox x23

endfunc

it's more complicated in the real script, it would be great if I could have a funcion called x and the I could call it and parse each parameter, I think I though of a way, I have to check it though...

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
Zinthose

I can't use that :)

I have a script but it's growing quite large cause I have to repeat stuff with slight differences, it would be easier if I could get a variable name and somehow change it so that the one function I have can work every time.

I have 10 tabs to do the same thing with different variables like

func 1

msgbox x1

msgbox x98

msgbox x54

endfunc

func 2

msgbox x9

msgbox x3

msgbox x23

endfunc

it's more complicated in the real script, it would be great if I could have a funcion called x and the I could call it and parse each parameter, I think I though of a way, I have to check it though...

Sounds to me like the functions need broken down further. Can you clarify more on what your trying to do?


--- TTFN

Share this post


Link to post
Share on other sites
qazwsx

sounds like you need an array.

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  

×