Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function

Status
Not open for further replies.

pvuppa1

Programmer
Nov 14, 2003
61
0
0
US
can anyone help me writing and calling a function with some parameters. here's wht i know
DEFINE FUNCTION fname(par1,par2)
....
...can i use it with some where clause using master file and return something

END
how can i call fname? to print the returned value.
 
You can return a value by setting the function equal to something. For example,

DEFINE FILE sample
WORK/i5=fname(par1,par2);
END

You can use IF, but I don't think you can use WHERE.
 
Thanks Pete,
I think I have to figure out some other way. I have to access same MAS file for different where conditions and with same parameter values. so i thought I can use a function.
Thanks again for ur time
-P
 
Sounds like you may want to use Dialogue Manager. DM can alter code based on different conditions. For example, a menu with & variables can be used to tell DM how to build code for a TABLE.
 
hOW TO USE DIALOGUE MANAGER. I dont see it in any of my tools and options on my webFOCUS Desktop developer studio 4.3.6
Please let me know
 
I don't remember developer studio dealing much with DM code, but you can insert the code yourself. You probably need to get a Focus manual. A simple example would be; if &REQUEST is 'A', I want to report on FIELD1. Otherwise, I want to use FIELD2. So...

TABLE FILE SAMEFILE
-SET &WORK=IF &REQUEST IS 'A' THEN 'FIELD1' ELSE 'FIELD2';
SUM &WORK
END

DM code can put intelligence into an application, but it can also get very complicated and extensive. It can READ, WRITE, DECODE, IF-THEN-ELSE, GOTO, call functions, default values, etc. That's why you need a manual.
 
Sample is

If you write in edasprpf the following

DEFINE FUNCTION WAYMD(INDATE/I8,ADD/I8,FMT/A2)
D01/A3=DOWK(INDATE,'A3');
D02/I8=AYMD(INDATE,ADD,'I8');
D03/I8=IF (D01 NE ' ') AND (D02 EQ 0) THEN 20031231 ELSE D02;
D04/A8=EDIT(D03);
D05/A8=IF FMT EQ 'I6' THEN EDIT(D04,'$$999999') ELSE D04;
WAYMD/I8=EDIT(D05);
END

You can
-SET &X=WAYMD(20031230,1,'I8'); in dialog

X/I8=WAYMD(20031230,1,X);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top