print("This is the important string I successfully passed: " || Eval(str1)) ;
vars4script = {"nine", "one", "two", "eight", "eleven"};
win_click = New Window( "journal window",
Spacer Box( size( 100, 10 ) ),
Header = Text Box( " journal window buttons", <<Font Color( " Blue" ) ),
Panel Box( " buttons1 ", buttons_area1 = H List Box() ),
Panel Box( " buttons2 ", buttons_area2 = H List Box() ),
Panel Box( " buttons2 ", buttons_area3 = H List Box() ),
);
//Method 1
For( i = N Items( vars4script ), i, i--,
str1 = vars4script[i];
buttons_area1 << Append( Button Box( Eval( str1 ), Include( "script2run.jsl", Eval( str1 ) ) ) );
);
//Method 2
For( i = N Items( vars4script ), i, i--,
str1 = vars4script[i];
buttons_area2 << Append(
Button Box( Eval( str1 ), <<Set Function( Expr( Include( "script2run.jsl", Eval( str1 ) ) ) ) )
);
);
//Method 3
For( i = N Items( vars4script ), i, i--,
str1 = vars4script[i];
buttons_area3 << Append( Button Box( str1, Eval Expr( "include('script2run.jsl', '$str1')" ) ) );
);
Is there a reason you need to do it this way? Unless you're constrained from some sort of extreme circumstances, your method of constructing an interactive GUI is not what you should be doing.
Consider using JMP classes -- these allow you to use methods directly as the callbacks on display elements and can greatly simplify GUI construction.
I consider building your UI in some other way, but if you really want to go the way you have suggested, this might work (I would not use this)
Names Default To Here(1);
vars4script = {"nine", "one", "two", "eight", "eleven"};
win_click = New Window("journal window",
Spacer Box(size(100, 10)),
Header = Text Box(" journal window buttons", <<Font Color(" Blue")),
Panel Box(" buttons1 ", buttons_area1 = H List Box()),
Panel Box(" buttons2 ", buttons_area2 = H List Box()),
Panel Box(" buttons2 ", buttons_area3 = H List Box()),
);
For(i = N Items(vars4script), i >= 1, i--,
Eval(EvalExpr(
buttons_area1 << Append(Button Box(vars4script[i],
str1 = Expr(vars4script[i]);
Expr(Parse(Load Text File("script2.jsl")));
));
));
);
In simple cases, you could most likely use a function and maybe button name as argument. Can you modify your generic script? Could it for example be included at the beginning of your script and then you call a function from that generic script within each of the buttons?
script1.jsl
Names Default To Here(1);
Include("script2.jsl");
vars4script = {"nine", "one", "two", "eight", "eleven"};
win_click = New Window("journal window",
Spacer Box(size(100, 10)),
Header = Text Box(" journal window buttons", <<Font Color(" Blue")),
Panel Box(" buttons1 ", buttons_area1 = H List Box()),
);
buttons_area1 << Append(
Button Box("nine", << Set Function(function({this},
my_func((this << Get Button Name));
)));
);
buttons_area1 << Append(
Button Box("one", << Set Function(function({this},
my_func((this << Get Button Name));
)));
);
script2.jsl
Names Default To Here(1);
my_func = function({str}, {Default Local},
Show(str);
);