[rkward-devel] JS in rkwarddev
meik michalke
meik.michalke at uni-duesseldorf.de
Tue Oct 27 10:46:47 UTC 2015
hi,
Am Dienstag, 27. Oktober 2015, 08:29:43 schrieb Thomas Friedrichsmeier:
> Very cool, indeed. Congrats! This addresses a whole lot of my
> concerns.
to be honest, i don't like using ifelse() either... i always wanted to be able
to use plain "if" conditions in the first place, but back then i had no clue
how to prevent R from evaluating such basic control elements. you successfully
pushed me to go dig deeper ;-)
> Pressing you some further, though: Will you be able to cover
> for()-loops, too?
i guess so.
basically, what i'm doing is to call eval(substitute(alist(...))) on a dots
argument of a function call, which will yield to a list of unevaluated R code.
try this:
dummy <- function(...){
return(eval(substitute(alist(...))))
}
dummyCalls <- dummy(
for (i in 1:10) {
paste(i)
}
)
as.list(dummyCalls[[1]])
it's pretty straight forward from then on -- see if dummyCalls[[1]] equals
"for", then dummyCalls[[2]] is the variable name, dummyCalls[[3]] the values
to go through and dummyCalls[[4]] the loop body. i hope ;-)
> (And will you still give me idq() so I know I can mix
> your high-level magic with "bare-to-the-bone" JS?)
i think except for the quotes you don't have to wait for it. you proposed:
rk.paste.JS ('var x = getString (', idq (x), ');'
something similar is possible with id():
rk.paste.JS (id("var x = getString ('", x, "');"))
the thing is that by courtesy rk.paste.JS() automatically adds a new line
after each comma, hence adding idq() would only solve (less than) half of the
problem. but you should be fine if you wrap everything inside
rk.paste.JS(id()) and take care of the quotes yourself.
viele grüße :: m.eik
PS: global variables are also implemented, see the "globals" argument of
?rk.JS.doc, which is also available in the "js" list argument of
?rk.plugin.component and ?rk.plugin.skeleton
--
dipl. psych. meik michalke
institut f"ur experimentelle psychologie
abt. f"ur diagnostik und differentielle psychologie
heinrich-heine-universit"at d-40204 d"usseldorf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20151027/07f3c602/attachment.sig>
More information about the rkward-devel
mailing list