AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pass an ahk variable to a javascript continuation section

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Sun Aug 10, 2008 10:46 pm    Post subject: Pass an ahk variable to a javascript continuation section Reply with quote

This may be a stupid question, or it may not be possible. What I'm trying to do is pass a variable's contents to a javascript instruction that, for means of readability, I want to keep in a continuation section. I'm using tank's awesome IE7 functions...

This should work...
Code:

IE7_ExecuteJS(myPageHandle, "for (i = 0; x <>'" name "'; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")


[edit] I don't know, maybe it should be %name% instead...
anyway...

My Javascript is pretty horrible so possibly i introduced a bug, but the idea is that i want to have the javascript code insert the value of name into the javascript...

The javascript section gets huge so i want to use a pretty continuation section... like
Code:

js =
(
for (i = 0; x <>" HOW DO I INSERT NAME HERE?

... etc...
; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")...
... etc.

Maybe I should have posted this in tank's thread, but I think that this is more of a formatting question and not specific to the IE7 functions.

Any help would be extremely appreciated... things look a lot prettier when I can include them in a variable/continuation section and pass that, instead of the 300 or 500 characters on 1 line that I'll end up needing.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 11, 2008 12:41 am    Post subject: Reply with quote

ug...
it occurs to me that I could do something like
Code:

js1 =
(
for (i = 0; x <> '
)

js2 =
(
'; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};"
)

and call it in a function as
Code:

IE7_ExecuteJS(myPageHandle, js1 . name . js2, "y")

Probably would work, but not as pretty...
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Mon Aug 11, 2008 12:48 am    Post subject: Reply with quote

Code:
js =
(
for (i = 0; x <>" %name%
; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")
)
IE7_ExecuteJS(myPageHandle, js, "y")



Question
Back to top
View user's profile Send private message AIM Address
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 11, 2008 2:22 am    Post subject: Reply with quote

For some reason i figured that since it would handle semicolons as javascript and not as an AHK comment, I couldn't use ahk style variables. Probably a dumb assumption.

I think this will work. Thanks.
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Mon Aug 11, 2008 2:45 am    Post subject: Reply with quote

http://www.autohotkey.com/docs/Scripts.htm#continuation
Describes default behavior for continuation sections, and how to change it.
Back to top
View user's profile Send private message AIM Address
Jex



Joined: 01 Aug 2008
Posts: 61

PostPosted: Mon Aug 11, 2008 3:12 am    Post subject: Reply with quote

write the variable to a file...then have javascript read the file. Smile

i know little on javascript...
_________________
Woot.

Please read forum etiquette
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group