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     [SOLVED] Math requiring MOD
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Math requiring MOD
 Login/Join
 
Master
posted
I'm currently doing paging within my own HTML and based on the total amount of records I need to divide the page display count, then add 1 if it's not MOD page display count = 0 like in .NET.

Example:
Total Count: 80
Page Display Count: 10

I need this page count value to be 8.

Total Count: 81
Page Display Count: 10

I need this page count value to be 9.

This code needs to only do the plus one if datatotal MOD pagesize NE 0 as it would in .NET

-SET &PAGECOUNT = (&DATATOTAL/&PAGESIZE);
-SET &PAGECOUNT = (&PAGECOUNT+1);

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



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Reply With QuoteReport This Post
Master
posted Hide Post
Try...
-SET &DATATOTAL = 81;
-SET &PAGESIZE = 10;

-SET &WORK = IMOD(&DATATOTAL, &PAGESIZE, 'I9');
-SET &WORK = IF &WORK EQ 0 THEN 0 ELSE 1;

-SET &PAGECOUNT = (&DATATOTAL/&PAGESIZE) + &WORK;

-TYPE DATATOTAL = &DATATOTAL
-TYPE PAGESIZE = &PAGESIZE
-TYPE PAGECOUNT = &PAGECOUNT  
 
Posts: 765 | Registered: April 23, 2003Reply With QuoteReport This Post
Master
posted Hide Post
Just one line of code needed ;-)


-SET &PAGECOUNT = INT ( ( &DATATOTAL + &PAGESIZE - 1 ) / &PAGESIZE );


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 669 | Location: Veghel, The Netherlands | Registered: February 16, 2010Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I just wrote code last week to do what you're wanting to do - &URECS is the number of records in my hold file, I want 50 records per page. I create a variable '&REMAINDER' and check the value of &REMAINDER when creating my counter field - I then loop &TABCTR times creating a compound spreadsheet.

 

-SET &REMAINDER = IMOD(&URECS, 50, 'I3L');
-SET &TABCTR = IF &REMAINDER EQ 0 THEN (&URECS/50) ELSE ((&URECS/50) + 1);


Using your fields:
-SET &REMAINDER = IMOD(&DATATOTAL, 10, 'I3L');
-SET &PAGECOUNT = IF &REMAINDER EQ 0 THEN (&DATATOTAL/&PAGESIZE) ELSE ((&DATATOTAL/&PAGESIZE)+1);

&ECHO RESULTS WITH 80 RECORDS:
 -SET &DATATOTAL = 80;
 -SET &PAGESIZE = 10;
 -SET &REMAINDER = IMOD(80, 10, 'I3L');
 -SET &PAGECOUNT = IF 0 EQ 0 THEN (80/10) ELSE ((80/10)+1);
 -TYPE 0
 0
 -TYPE 8
 8
 -EXIT

&ECHO RESULTS WITH 81 RECORDS:
 -SET &DATATOTAL = 81;
 -SET &PAGESIZE = 10;
 -SET &REMAINDER = IMOD(81, 10, 'I3L');
 -SET &PAGECOUNT = IF 1 EQ 0 THEN (81/10) ELSE ((81/10)+1);
 -TYPE 1
 1
 -TYPE 9
 9
 -EXIT
 


 


WF 7.7.05
HP-UX - Reporting Server, Windows 2008 - Client, MSSQL 2008, FOCUS Databases, Flat Files
HTML, Excel, PDF
 
Posts: 149 | Location: Dallas, TX | Registered: June 08, 2007Reply With QuoteReport This Post
Master
posted Hide Post
quote:
-SET &WORK = IMOD(&DATATOTAL, &PAGESIZE, 'I9');
-SET &WORK = IF &WORK EQ 0 THEN 0 ELSE 1;

-SET &PAGECOUNT = (&DATATOTAL/&PAGESIZE) + &WORK;


Perfect! I couldn't find any MOD commands.. I think I have help file block syndrome.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Math requiring MOD

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