473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need to get a javscript variable into my tcl code

Hello,

I have a difficult task I believe. I have tcl code that opens a
webpage, then via execScript commands calls javascript code to play
audio files for my js object player. The problem is that I need to know
when the clip is done for example to have my tcl code check for that.

Has anyone been able to pass a javascript variable to tcl code, or has
had a work around to this??

Here is what I have so far:

tcl code (I am using optcl to open the page in a tk window):

# set tk window
package require optcl
set t [toplevel .ie]
wm title $t "my Test"
set htm [optcl::new -window $t.htm Shell.Explorer.2]
$t.htm config -width 800 -height 600
pack $t.htm -fill both -expand 1

# Open the page
$htm navigate "c:/test/v1fe.htm"

#### This is not the right way to get the variable
# A test to see if I can get a variable from javascript, it doesnt work
cause execScript passes null
set myVar [[$htm -with Document : parentWindow] execScript
{javascript:myfunction ()}]
puts $myVar
my javascript code:
<script type="text/javascript">
<!--
// Test to pass value 1 to tcl code
function myfunction()
{
return(1)
}
//-->
</script>

Any suggestions/examples??

Thanks,

Bandaar

Nov 23 '05 #1
3 4044
VK
<snip code sample>
I have no idea what browser are you working with, but presuming that
<execScript> method has the same mechanics as in IE (that's the only
execScript I know of):

1) execScript always returns null, you cannot return any results from
it.
2) execScript runs in the restricted environment. In the particular it
cannot create new property in DOM objects *but* it can change the
existing ones.

Combining both issues (sorry, I don't know TCL, so pseudo code):

1. [create] window.tmpReturnValue property
2. [run] execScript( myFunction() )
3. myFunction [set] window.tmpReturnValue to some return value
4. myFunction [exit]
5. [read] window.tmpReturnValue

I had to use this side walk to access VBScript dialogs from JScript and
get the user choice back.
Not sure at all though if it works in you situation.

Nov 23 '05 #2
Hi VK,

Thanks for the reply.
1) execScript always returns null, you cannot return any results from
it.
I found that out the hard way, trying all sorts of stuff for hours to
capture a variable...Dooooh!
2) execScript runs in the restricted environment. In the particular it
cannot create new property in DOM objects *but* it can change the
existing ones.
I'm not familiar with DOM objects. Is this Microsoft activex Com
objects?
The problem is I'm a bit clueless using tcl in sophisticated ways, such
as using OPTCL and active x stuff, so bear with me.

Combining both issues (sorry, I don't know TCL, so pseudo code):

1. [create] window.tmpReturnValue property
2. [run] execScript( myFunction() )
3. myFunction [set] window.tmpReturnValue to some return value I think my code is doing #1,2,&3 (w/ help from a tcl guru)??
[$htm -with Document : parentWindow] execScript {var
result={javascript:myfunction ()}}

I do this on the javascript side right??
4. myFunction [exit] Not sure how to do this. I didn't know you have to exit the function?
execScript just calls the function, correct?
5. [read] window.tmpReturnValue

Also not sure how to read. This is on the tcl side?

Thanks for the direction. Any suggestions?

Regards,

Bandaar

Nov 23 '05 #3
VK
<snip>

Again - I never used TCL, so I'm just guessing the syntacs:

# set tk window
package require optcl
set t [toplevel .ie]
wm title $t "my Test"

# By the context $t must refer to the IE window
# So it should added a new custom property to the window like:
# wm tmpReturnValue $t ""
# - Please fing the right syntacs yourselve

set htm [optcl::new -window $t.htm Shell.Explorer.2]
$t.htm config -width 800 -height 600
pack $t.htm -fill both -expand 1

# Open the page
$htm navigate "c:/test/v1fe.htm"

# this always gives you null so useless:
set myVar [[$htm -with Document : parentWindow] execScript
{javascript:myfunction ()}]

# you have to read $t.tmpReturnValue property instead
# - Please fing the right syntacs yourselve
my javascript code:
<script type="text/javascript">
<!--
function myfunction()
{
myReturnValue = 'OK';
window.tmpReturnValue = myReturnValue;
}
//-->
</script>

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stacey | last post by:
Here is a function that is declared in my html page. It is part of a series of javascript that allows the user to draw a rectangle on a graphic. This is called when the box is done, so I would...
1
by: Neil Cherry | last post by:
What I'm basically trying to do is call a Java applet public method ( public void setInterval(int i) {...} ) from javascript in Firfox 1.0.7. I've not done this before but most of google agrees...
3
by: mistral | last post by:
Here is javscript clock: http://javascript.internet.com/time-date/mousetrailclock.html which I want adjust a little: 1. I want replace the days of week/year/date in external circle with just...
2
by: sagel | last post by:
im trying to iterate thru form elements and pull out the ones with "note" in their name. getting "elementName has no properties" with the following code, and i don't understand why? any help is...
4
by: pbd22 | last post by:
Hi. I have an ajax question. I am wondering if it is possible to get the response from a method within a given page, and that function alone? Traditionally, I have been getting the response...
4
by: iamthebest | last post by:
Hello, I am trying to call a javscript function from c#. But it is not getting called. The error comes up saying funtionname is not defined even though it is defined and visible in page source. ...
1
by: manojuniverse | last post by:
Hi can any body help me in knowing in javscript on client side whether session has expired or not. Plz help me. Thanks in advance.
4
by: Cirene | last post by:
I have javascript code that does an alert on a public asp.net var... alert("<%=strMessage%>"); The code runs whenever my ajax related code completes. I declared the public var like this......
3
by: waqasahmd | last post by:
Hi, I have this code in my pageload but the problem is i want rm_id which i am gettin from session should be set in the javascript code in place of 261 hard code value at line#5( var rmid = 261;) ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.