@hogi wrote:
a check + warning functionality ...
myscript = Parse( Current Window()[Script Box( 1 )] << get text );
variables = {};
// find the assignments and collect the JSL variables
assigns = Extract Expr All Matches(
Name Expr( myscript ),
Expr( Assign( Wild List() ) )
);
For Each( {item}, assigns, Insert Into( variables, Arg( item, 1 ) ) );
// collect the messages
messages = Extract Expr All Matches(
Name Expr( myscript ),
Expr(
Send( Wild(), Wild List() )
)
);
For Each( {message}, messages,
// bother an experienced user just when he forgot to use Expr:
// assuming there is a surrounding Eval (Eval Expr()), remove all the Expr() - including the content [dirty]
Extract Expr All Matches(
Arg( Name Expr( message ), 2 ),
Expr( Expr( Wild List() ) )
); // returns: cleanedExpr, without the Expr()s
//search for variables
For Each( {variable, idx}, variables,
If(
Not(
Is Empty(
Eval(
Eval Expr(
Extract Expr(
Expr(
Name Expr( cleanedExpr )
),
Expr( Name Expr( variable ) )
)
)
)
)
),
Caption(
Char( variables[idx] ) || " found in a message to " ||
Char( Arg( Name Expr( message ), 1 ) ) ||
".\!n Please correct it with Eval(Eval Expr( ... Expr()))"
);
Stop();
)
);
);
//Extract Expr All Matches?
// it works like Extract Expr, but doesn't stop after the first match.
// saves the "cleaned" expression as cleanedExpr