Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Passing a random number in FOCEXEC
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Passing a random number in FOCEXEC
 Login/Join
 
Silver Member
posted
Hi,

I want to pass a random number in FOCEXEC of the parent that calls the child fex. This way every time the child is invoked from the parent,a different random number will be passed in the URL.

For example,
-SET &ACROSSCOLNAME = 'DUMMY';
-SET &TMPFORMAT = 'monthly';
-SET &METmetric1 = 'Peak_Volume';
-SET &FUNmetric1 = 'SUM';
-SET &PARFEX = 'r16489';
-SET &SERIES1WIDTH =1 ;
-SET &SERIES1TYPE =1 ;
-SET &SERIES1TYPE=1;
-SET &SERIES1AXIS=0;
-SET &RANDOM = RDUNIF('D4.3') * 100;
.
.
-* I am passing the above values in FOCEXEC to a child fex,

TYPE=DATA, ACROSSCOLUMN=metric1, COLOR=RGB(255 153 255),
FOCEXEC=&PARFEX(DATE_TIME=TIMECOL ACROSSCOL_NAME='&ACROSSCOLNAME'
ACROSSCOL_VAL=acrosscol COLNAME ='&METmetric1' FUNC ='&FUNmetric1'
FORMAT='&TMPFORMAT' ROUTETYPE='CHILD' TYPE='&SERIES1TYPE' RANDOM = '&RANDOM'
),TARGET=_blank, $
ENDSTYLE

But when the URL is passed with the paramters,the RANDOM value remains the same always. But I need something like this :
Every time I click on a bar, a link with different RANDOM numbers need to be generated.

Is there something that should be done with Javascript to overwrite the inital value,every time another action occurs.?

This message has been edited. Last edited by: Kerry,


769
Windows

Using all the above
 
Posts: 34 | Registered: August 08, 2009Reply With QuoteReport This Post
<JG>
posted
Correct Javascript, several examples on the forum.

As an easy alternative try using -SET &RAND=HHMMSS('A8'); in the focexec and pass that &RAND.

That will make it different for every run.
 
Reply With QuoteReport This Post
Silver Member
posted Hide Post
This does'nt work. When we SET a variable and then try to pass that variable in the FOCEXEC, the value does not change since the function does not get executed.


769
Windows

Using all the above
 
Posts: 34 | Registered: August 08, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
I assume that your parnet report does not get refreshed, therefore the & value of random does not get refreshed.

Javascript is the simplest way.

The question then is wich way, you could just create a form and populate the random value on submitting it.

You could also create a script that searched through your links and updates the value.

There are probably many other options as well.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6104 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Silver Member
posted Hide Post
Can you please send me an example.?


769
Windows

Using all the above
 
Posts: 34 | Registered: August 08, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Here is an example of updating the drilldown its self.

It is set to update every 10 seconds.

This will only work for HTML reports, and I've only tested with IE.

TABLE FILE CAR
PRINT COUNTRY
ON TABLE SET STYLE *
 TYPE=DATA, FOCEXEC=DRILL(RANDOM=''), $
ENDSTYLE
END

-RUN

-HTMLFORM BEGIN
<script language="JavaScript">
<!--
  function setRandom() {
    var anc_list = document.getElementsByTagName("A") ;
    for (var _c1=0;_c1<anc_list.length;_c1++) {
      var _bits = anc_list[_c1].href.toString().split('=') ;
      _bits[_bits.length-1] = new Date() ;
      anc_list[_c1].href = _bits.join('=') ;
    }
    alert(document.body.innerHTML) ;
    window.setTimeout('setRandom()',10000) ;
  }
  setRandom() ;
//-->
</script>
-HTMLFORM END


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6104 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
Hey Waz,

That sounds like something that can be added to an on_click event where "var" can be incremented and used in the drilldown code... I'll see if I can come up with something that does that. But, I'm off for the night. So, feel free to do it to it...

Doug
 
Posts: 2976 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
Hey Doug, that a good idea.

Here is my simple one.

TABLE FILE CAR
PRINT COUNTRY
ON TABLE SET STYLE *
 TYPE=DATA, FOCEXEC=DRILL(RANDOM=''), $
ENDSTYLE
END

-RUN

-HTMLFORM BEGIN
<script language="JavaScript">
<!--
  function setOnClick() {
    var anc_list = document.getElementsByTagName("A") ;
    for (var _c1=0;_c1<anc_list.length;_c1++) {
      anc_list[_c1].onclick = function() {setRandom(this);}
//      anc_list[_c1].onmouseover = function() {setRandom(this);}
    }
  }
  function setRandom(_anchor) {
    var _bits = _anchor.href.toString().split('=') ;
    _bits[_bits.length-1] = new Date() ;
    _anchor.href = _bits.join('=') ;
    alert(_anchor.href) ;
  }
  setOnClick() ;
//-->
</script>
-HTMLFORM END


You could also do it with an onmouseover event.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6104 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Virtuoso
posted Hide Post
One could also be "pure focus".
Calling fex:
  
-* File PassRandom.fex
DEFINE FILE CAR
RD/D3 WITH SALES=RDUNIF('D4.3') * 100;
END
TABLE FILE CAR
SUM SALES
FST.RD NOPRINT
BY COUNTRY
BY CAR
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
TYPE=DATA, COLUMN=SALES, FOCEXEC=GETRANDOM(COUNTRY=COUNTRY CAR=CAR RD=FST.RD), $
ENDSTYLE
END


Called Fex:
-* File GetRandom.fex
-TYPE COUNTRY=&COUNTRY
-TYPE CAR=&CAR
-TYPE RANDOM=&RD


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1932 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Silver Member
posted Hide Post
Hi,

Thanks for the response. The javascript code works fine for the tables. Upon clicking on the link, it takes me to the URL that has the random values poplualted. But this works fine only when we click on a link (href). What am I supposed to do to make this work in the graph. When a bar is clicked the URL is populated without the random value.

GRAPH FILE CAR
SUM SALES
ACROSS COUNTRY

ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET 3D OFF
ON GRAPH SET BARNUMB OFF
ON GRAPH SET GRID ON
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET GRMERGE ON
ON GRAPH SET VZERO OFF

ON GRAPH SET STYLE *



TYPE=DATA,COLUMN=N1,FOCEXEC=TEST(RANDOM = ''), $


ENDSTYLE
END
-RUN
-HTMLFORM BEGIN

<script language="JavaScript">
function setRandom() {
var anc_list = document.getElementsByTagName("A") ;
for (var _c1=0;_c1 var _bits = anc_list[_c1].href.toString().split('=') ;
_bits[_bits.length-1] = new Date() ;
anc_list[_c1].href = _bits.join('=') ;
}
window.setTimeout('setRandom()',10000) ;
}

setRandom() ;

-HTMLFORM END

Thanks
Priya.


769
Windows

Using all the above
 
Posts: 34 | Registered: August 08, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Try this:

-* File random4.fex

GRAPH FILE CAR
SUM SALES
ACROSS COUNTRY
BY BODYTYPE

ON GRAPH SET GRMERGE ON

ON GRAPH SET STYLE *
TYPE=DATA, JAVASCRIPT=runfex (COUNTRY BODYTYPE), $
ENDSTYLE
END
-RUN

-HTMLFORM BEGIN
<script type="text/javascript">

function runfex(country, bodytype)
{
random = Math.floor((Math.random()*100000));
url = 'WFServlet?&|IBIAPP_app=test&|IBIF_ex=RANDOM2&|COUNTRY=' + country + '&|BODYTYPE=' + bodytype + '&|RANDOM=' + random;

fexwindow = window.open(url, 'fexwindow');
fexwindow.focus();
}
</script>

-HTMLFORM END
-EXIT


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
As GRAPHEDIT SERVER creates an image and then mapps the drilldoes with the AREA tag, the change is simple.

GRAPH FILE CAR
SUM SALES
ACROSS COUNTRY

ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET 3D OFF
ON GRAPH SET BARNUMB OFF
ON GRAPH SET GRID ON
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET GRMERGE ON
ON GRAPH SET VZERO OFF

ON GRAPH SET STYLE *



TYPE=DATA,COLUMN=N1,FOCEXEC=TEST(RANDOM = ''), $


ENDSTYLE
END
-RUN
-HTMLFORM BEGIN
<script language="JavaScript">
<!--
  function setRandom() {
    var anc_list = document.getElementsByTagName("AREA") ;
    for (var _c1=0;_c1<anc_list.length;_c1++) {
      var _bits = anc_list[_c1].href.toString().split('=') ;
      _bits[_bits.length-1] = new Date() ;
      anc_list[_c1].href = _bits.join('=') ;
    }
    alert(document.body.innerHTML) ;
    window.setTimeout('setRandom()',10000) ;
  }
  setRandom() ;
//-->
</script>
-HTMLFORM END


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6104 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Passing a random number in FOCEXEC

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.