IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Trying to reference a javascript global variable in rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Jeff Kirsch

New User


Joined: 23 Jun 2021
Posts: 6
Location: USA

PostPosted: Mon Jul 26, 2021 8:36 am
Reply with quote

Hi,

I've read a number of posts and some topics about javascript and rexx co-existing together. And, I've written a very basic rexx program that uses some simple html and javascript.

What I'm trying to do, presuming it can be done and I just don't know the magic, is reference a global variable defined in javascript within the rexx program.

The javascript and rexx command I've defined both reside in the same program. For example

say '<script language="javascript" type="text/javascript">'
say '{var counter = 2}'
say '</script>'

say '<script language="javascript" type="text/javascript">'
say 'function myTest()',
'{alert(counter)}'
say '</script>'

say counter


In the above example, the global variable counter is assigned a value of 2, and will display that value when function myTest() is executed. However, the Rexx command which follows say counter only displays the word COUNTER.

If this can be done, would someone educate me on how this can be accomplished? Thanks in advance.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Mon Jul 26, 2021 9:29 am
Reply with quote

Don't you miss some semicolon in your code, do you?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Mon Jul 26, 2021 11:02 am
Reply with quote

Jeff, can you cite a reference for this? I would like to try it out.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Mon Jul 26, 2021 11:18 am
Reply with quote

I do not know anything about this. This is all guessing, hypothesis and conjecture:

In your example, it seems like the rexx would run on the web server and it will build an HTML file that will run sometime later on the browser system. I think all of the rexx will run before any of the javascript is run.

That is, in your example rexx, it only has several SAY instructions which are used to compose the HTML file but there is no other execution going on.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Mon Jul 26, 2021 11:21 am
Reply with quote

It is not clear what myTest() is... is that also a rexx program?
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Mon Jul 26, 2021 3:43 pm
Reply with quote

Pedro wrote:
It is not clear what myTest() is... is that also a rexx program?

it should be seen as the JS function. But I doubt that REXX can also run JS code.. icon_surprised.gif
Code:
function myTest() {alert(counter)};
*afaik*
Back to top
View user's profile Send private message
Jeff Kirsch

New User


Joined: 23 Jun 2021
Posts: 6
Location: USA

PostPosted: Mon Jul 26, 2021 8:51 pm
Reply with quote

Hi Pedro and Joerg,

Thanks for your replies, let me respond:

"Can you cite a reference for this? I would like to try it out"
-- I don't have a reference for you, sorry. The code I wrote is from other systems that were written using Rexx. It's been trial and error as I read about javascript and HTML, then incorporate it into Rexx.

In your example, it seems like the rexx would run on the web server and it will build an HTML file that will run sometime later on the browser system. I think all of the rexx will run before any of the javascript is run.
That is, in your example rexx, it only has several SAY instructions which are used to compose the HTML file but there is no other execution going on.

-- Yes, I'm using Rexx on a webserver executing under USS. You may be right in that Rexx statements execute first before the javascripts get invoked. I don't know how it all works behind the scenes either. The "say" statements are executing. Because I do see the webpage with my objects displayed, and when I click on them, they execute the function I specified.

It is not clear what myTest() is... is that also a rexx program?
-- That is a javascript function. All it does is displayed the value of counter. And it works, so that is how I know the variable counter has been populated.

It should be seen as the JS function. But I doubt that REXX can also run JS code.
-- You may be right in that Rexx may not run the JS code, but the webserver is. Rexx cgi-script I think just allows the code to be generated so javascript can execute it.

As I mentioned in my opening comment, it may not be possible to reference a javascript variable or HTML object from Rexx. But wanted to check just the same.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Mon Jul 26, 2021 9:24 pm
Reply with quote

Quote:
it may not be possible to reference a javascript variable or HTML object from Rexx

You are in control of the entire thing. You could do something like this:
Code:

counter=2
say '<script language="javascript" type="text/javascript">'
say '{var counter = 'counter'}'
say '</script>'

say '<script language="javascript" type="text/javascript">'
say 'function myTest()',
'{alert(counter)}'
say '</script>'

say counter

But I think that is not what you want. You probably want to get an updated value from the user/browser to the server.

I think you will need to issue cgi-script POST statement to get information from the browser to the server.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to modify file content using REXX CLIST & REXX 3
No new posts Same command as on commandline in REX... TSO/ISPF 6
No new posts Merge a variable number of records fr... DFSORT/ICETOOL 5
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts REXX SDSF filtering CLIST & REXX 8
Search our Forums:

Back to Top