eval function

Hello,

I’m keen for some debugging function to use: evel( name1 + name2)
It should be somewhere there in javascript :mrgreen:

but i get this error:

Source not found for module [forms/pnl_TransHorExpansion.js#142(eval): 1]

This is the code:

	try {
		var mcvts = 'bthdr_dist_sh_2ftip_hot';          
		eval('frm_v_' + mcvts) = eval('calc_' + mcvts);
		
		application.output('311 - 1 = ' + calc_bthdr_dist_sh_2ftip_hot);
	} catch (err) {
		application.output('311 - 1 ERR');
	}

Help is appreciated.

grz, Jan

Should i load something?

Try this:

eval('frm_v_'+mcvts+'=calc_'+mcvts)

Thx for your reply, Juan

Tried it … did’nt help

Maybe I did not understand what you are trying to do but this code works for me:

	var v1='a';
	var v2='1';
	var v3='b';
	var v4='1';
	var a1='juan ';
	var b1='antonio';
	var c=eval(v1+v2+'+'+v3+v4);
	application.output(c);

result is juan antonio

I think he wants to change the value of a form variable, am I right Jan?

Yes Peter,

In this case it was form var. That’s why it does not work (apparently)
Thanks for replying … :)

Some time for debug purp. i code stuff like this:

function test_eval() {
	//eval test
	var prefix = 5;
	var t2          = 'Suffix';
	var calc_Suffix = 4;
	
	application.output('prefix = ' + eval('calc_' + t2));
	application.output(eval('calc_' + t2));
}

Here eval works… :)

Kind regards, Jan

Good morning from Gran Canaria Jan.

Maybe you can use this code:

var a1="varPrefix";
var a2="varSuffix";

forms.myForm[a1+a2]="My new value";

There is a form variable in myForm declared as VarPrefixvarSuffix