[question] Deref / Expression in String Topic is solved

Discuss the future of the AutoHotkey language
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[question] Deref / Expression in String

29 Aug 2017, 03:58

a079 Deref() omited.
Will be there in the future some method to resolve only variable value in expression (not variable alone) stored in string without evaluation?

Code: Select all

a:= "A_Index+13"
deref(a) => "<value>+13" for example "4+13"
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[Solution] [question] Deref / Expression in String  Topic is solved

29 Aug 2017, 06:01

Crazy people self asked self answered - partial solution - edited "while" prevent using A_Index and all loop variables

Code: Select all

variable:= 333
_MyOwn1_2Var23:= 5

; deref ------------------------------------------------- AutoHotkey_2.0-a081-cad307c
__deref_Expression:= "123 + %_MyOwn1_2Var23% + 13 + %Variable% / %_MyOwn1_2Var23%"
__deref_LABEL: 
	if RegExMatch(__deref_Expression, "i)[%][a-z_]\w*[%]", __deref_Variable) {
		__deref_Expression:= RegExReplace(__deref_Expression
										, "i)" __deref_Variable.Value
										, %subStr(__deref_Variable.Value, 2, -1)% "")
		goto __deref_LABEL
} ; ---------------------------------------------------------------------------------
msgBox(__deref_Expression)
Code replace variables with there values.
Due to no inline function or macros and variable scope this code must be stored at the place where variables must be deref.
Evaluation from tidbit

Code: Select all

dd_tidbitEval(expression) { ; 
	obj:=ComObjCreate("HTMLfile")  ;tidbit code ------------------------------------
	obj.write("<body><script>document.body.innerText=eval('" expression "');</script>") ;--
	return obj.body.innerText
}
Functions not allowed.

Enjoy!
AHKv2.0 alpha forever.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [question] Deref / Expression in String

01 Sep 2017, 00:09

Hello. Interesting code. Maybe this will interest you, function macro, see the example.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Re: [question] Deref / Expression in String

01 Sep 2017, 02:50

Helgef wrote:Hello. Interesting code. Maybe this will interest you, function macro, see the example.
AutoHotkey_2.0-a081-cad307c

Code: Select all

; Call to nonexistent function.
; Specifically: macro
macro mFunc(arg) {
	arg:= 1
}
AHKv2.0 alpha forever.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [question] Deref / Expression in String

01 Sep 2017, 03:04

Sorry I didn't specify, it is for ahk_h.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 23 guests