Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
Custom functions
 Login/Join
 
Member
posted
Hi,

I am trying to write my own function to perform some task.
Why does the following code not work?
DEFINE FUNCTION SUBTRACT (VAL1/D8, VAL2/D8)
SUBTRACT/D8.2 = VAL1 - VAL2;
END

-SET &myvar=SUBTRACT(3,1);

I could successfully use the subtract function in a statement such as:
...
PRINT
EVENT_TYPE_EN AND COMPUTE PROFIT/D8.2 = SUBTRACT(3,1);
...

So why can I not do:
-SET &myvar=SUBTRACT(3,1);

Thank you for your assistance.

-Daniel.,
 
Posts: 20 | Registered: April 05, 2006Report This Post
Virtuoso
posted Hide Post
The define function is for "Focus" based code only. Therefore, it will not work with Dialog Manager (any line that starts with a '-' as in -SET). That means that you can use the function with defines and computes - not so sure about whens.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
Really? then how does this code function?
DEFINE FUNCTION ELAPSED(X/A1)
DAY/YYMD = HDATE(TODAY('A10'),'YYMD');
DATE/A6YMD = DAY;
BEGTIME/A8 = EDIT('&TOD.EVAL', '99$:99$:99');
ENDTIME/A8 = EDIT(HHMMSS('A8'), '99$:99$:99');
BEGAN/A20 = DATE | ' ' | BEGTIME;
ENDED/A20 = DATE | ' ' | ENDTIME;
-* Convert to time stamps
DATE_TIME1/HYYMDSA=HINPUT(20,BEGAN,10,'HYYMDS');
DATE_TIME2/HYYMDSA=HINPUT(20,ENDED,10,'HYYMDS');
-*Subtract the two time stamps, getting difference in seconds
ELAPSED/D12.2=HDIFF(DATE_TIME2, DATE_TIME1, 'SECOND', 'D12.2');
END
-RUN

-* Find elapsed time
-SET &ELAPSED = ELAPSED('X');

-TYPE Elapsed Time (in seconds): &ELAPSED
-RUN


The answer is that you need to ensure the function SUBTRACT is loaded into memory by issuing a -RUN after the END statement
DEFINE FUNCTION SUBTRACT (VAL1/D8, VAL2/D8)
SUBTRACT/D8.2 = VAL1 - VAL2;
END
-RUN
-SET &myvar=SUBTRACT(3,1);


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Member
posted Hide Post
Thanks Tony that worked!
 
Posts: 20 | Registered: April 05, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders