JavaScript in a command

K.V.

Hello all,

I'm trying to make this command work:

Command pattern:
JS.#text#

msg (text)
JS.addText(text)
JS.text

> JS.hideBorder()
hideBorder()
hideBorder()

> JS.hideBorder
hideBorder
hideBorder


How do I convert text to something JS understands?

gmail.com

yahoo.com


K.V.

I think I need to be converting a string to an expression/value, because this doesn't work either...

Can a variable even be an expression (or a value)?

Command pattern:
request (#text#)

msg (text)
text = Split(text, ",")
msg (ListItem(text, 0))
text1 = (ListItem(text, 0))
msg (ListItem(text, 1))
text2 = (ListItem(text, 1))
request (text1, text2)

> request (Hide, "Panes")
Hide, "Panes"
Hide
"Panes"
Error running script: Requested value 'text1' was not found.


For the first use

JS.eval(text)

The second will not work because the first parameter to request should not be s string. I am not sure what to call what it is but you cannot convert to it from a string.


K.V.

Thanks, Pixie!


K.V.

Got this one working (only for Show and Hide so far, but the remaining 21 cases will be added shortly (and yes: I've gone slightly insane)):

request (#text#)

text = Split(text, ",")
t1 = (StringListItem(text, 0))
t2 = (StringListItem(Split((StringListItem(Split((StringListItem(text, 1)), " "), 1)), "\""), 1))
msg (t2)
switch (t1) {
  case ("Hide") {
    request (Hide, t2)
  }
  case ("Show") {
    request (Show, t2)
  }
}

K.V.

...now I need to learn the RegEx to check the formatting up front...

request (Text, "Text")

I don't need to do Update Location, Quit, Save, Pause, or Wait (unless I could check for those quotation marks, with or without anything in between them, but I don't know if that's too much for RegEx (but surely it's not)).


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums