Focal Point
TRUNCATE function - is it documented?
September 06, 2007, 01:32 PM
Francis MarianiTRUNCATE function - is it documented?
I cannot find any documentation for the TRUNCATE function in the 5.3.2 docs. Is it documented in a newer release?
It appears that it only works in Dialogue Manager, I tried it in a DEFINE and got
(FOC263) EXTERNAL FUNCTION OR LOAD MODULE NOT FOUND: TRUNCATE
I realize it may not make sense to use it in a DEFINE.
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
September 06, 2007, 02:00 PM
GlendaI'm on version 536 and the TRUNCATE function does not exist. I receive the same error message you are getting.
This is how we do it:
DEFINE FILE CAR
TAX/D12.4 = .08125;
SALESTAX/D12.4 =
TRUNC_SALESTAX/D12.2 = EDIT(STRIP(14,SUBSTR(14, FTOA(SALESTAX*100, '(D12.2)', 'A14'), 1,
(POSIT(FTOA(SALESTAX*100, '(D12.2)', 'A14'), 14, '.', 1, 'I2'))-1, 14, 'A14'), ',', 'A14'))/100;
DRIVEOUT/D12.2 = TRUNCATE(RETAIL_COST * TAX);
END
-*
TABLE FILE CAR
PRINT
RETAIL_COST
TAX
SALESTAX
TRUNC_SALESTAX
DRIVEOUT
ON TABLE PCHOLD FORMAT EXL2K
END
I'm sure there is a shorter way but this is the one I came up with on the fly.
Glenda
Glenda
In FOCUS Since 1990
Production 8.2 Windows
September 06, 2007, 02:02 PM
GlendaDEFINE FILE CAR
TAX/D12.4 = .08125;
SALESTAX/D12.4 = RETAIL_COST * TAX;
TRUNC_SALESTAX/D12.2 = EDIT(STRIP(14,SUBSTR(14, FTOA(SALESTAX*100, '(D12.2)', 'A14'), 1,
(POSIT(FTOA(SALESTAX*100, '(D12.2)', 'A14'), 14, '.', 1, 'I2'))-1, 14, 'A14'), ',', 'A14'))/100;
DRIVEOUT/D12.2 = TRUNCATE(RETAIL_COST * TAX);
END
TABLE FILE CAR
PRINT
RETAIL_COST
TAX
SALESTAX
TRUNC_SALESTAX
DRIVEOUT
ON TABLE PCHOLD FORMAT EXL2K
END
Glenda
In FOCUS Since 1990
Production 8.2 Windows
September 06, 2007, 02:05 PM
GlendaOk, I must be sleeping. I don't know what happened on the first post.
The second was where I tried the truncate function to see what the error message was I received.
If you take out
DRIVEOUT/D12.2 = TRUNCATE(RETAIL_COST * TAX);
the query will run.
Sorry for all the confusion.
I think I'll go take a nap now
Glenda
In FOCUS Since 1990
Production 8.2 Windows
September 06, 2007, 02:09 PM
Leahquote:
(FOC03665) Error loading external function 'TRUNCATE'This function can only be used in Dialogue Manager commands that support function calls, such as ‑SET and ‑IF commands. It cannot be used in ‑TYPE or ‑CRTFORM commands or in arguments passed to stored procedures.
You can't use it in a define statement. OR maybe you can based on Glenda's test but that's a numeric calculation she's doing so who knows.
Leah
September 06, 2007, 02:24 PM
GlendaLeah,
Your are correct. I don't use the TRUNCATE function. Instead, I came wrote a numerica calculation to use in place of the TRUNCATE function.
Glenda
In FOCUS Since 1990
Production 8.2 Windows
September 06, 2007, 02:24 PM
jimster06Here's where the doco is
http://documentation.informationbuilders.com/masterinde...g/source/topic44.htmAnd it works in DM only.
jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
September 08, 2007, 10:39 AM
susannahalthough it would take me more than a long nap to understand Glenda's DEFINE's... ( we need a smiley for head spinning out of control)
if what you want to do is essentially ROUNDDOWN an end result, then you can write your own TRUNCATE function and stick it in your edasprof.
eg:
-SET &ECHO = ALL ;
DEFINE FILE CAR
SALESTAX/D9.4 = .0825 ;
TAX/D9.4=SALES * SALESTAX;
temp1/I9=( TAX * 100) ;
rightanswer/P9.2=temp1/100;
wronganswer/P9.2= TAX;
END
TABLE FILE CAR
PRINT SALES SALESTAX TAX temp1 rightanswer wronganswer
COMPUTE OOPS/D9.2S=rightanswer - wronganswer;
ON TABLE HOLD AS MYTAB FORMAT HTMTABLE
END
-RUN
-STEP2
DEFINE FUNCTION F_TRUNC(number/D9.4)
temp1/I9= number * 100 ;
F_TRUNC/P9.2= temp1/100;
END
DEFINE FILE CAR
SALESTAX/D9.4 = .0825 ;
rightanswer/P9.2=F_TRUNC(SALES * SALESTAX);
END
TABLE FILE CAR
PRINT SALES SALESTAX rightanswer
ON TABLE HOLD AS MYTAB1 FORMAT HTMTABLE
END
-RUN
-HTMLFORM BEGIN
<TABLE><TR><TD>
!IBI.FIL.MYTAB;
<TD>!IBI.FIL.MYTAB1;
</TABLE>
-HTMLFORM END
| In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID |
September 10, 2007, 09:18 AM
GlendaSorry about that. I'm not quite the experts you all are.
Glenda
In FOCUS Since 1990
Production 8.2 Windows
September 10, 2007, 09:24 AM
LeahOf course this is silly to ask now, Francis, but are truncating numbers or character strings?
Leah
September 10, 2007, 11:00 AM
Francis MarianiI was truncating character strings. Since I used TRUNCATE to concatenate First Name and Last Name Dialogue Manager variables, I thought I would modify the technique I use in a COMPUTE or DEFINE to use TRUNCATE instead of hard concatenation with a blank in between. But TRUNCATE only works in Dialogue Manager.
Cheers.
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