Focal Point
DEFINE FUNCTION with variable length return

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2431058092

July 08, 2008, 10:06 AM
hammo1j
DEFINE FUNCTION with variable length return
Trying to write function using DEFINE FUNCTION

NOCRLF(inlen,indata) to remove CR and LF

eg CLEANSTR/A67 = NOCRLF(67,PART_NO) ;

Cannot see how to code a variable return format eg for TEMP and NOCRLF

DEFINE FUNCTION NOCRLF(INLEN, INDATA/A256) ;
TEMP/A67 = STRREP (INLEN,INDATA, 1, HEXBYT(13, 'A1'), 1, ' ',INLEN, TEMP);
NOCRLF/A67 = STRREP(INLEN,TEMP, 1, HEXBYT(10, 'A1'), 1, ' ', INLEN, NOCRLF);
END

Anybody know how to do this?



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
July 08, 2008, 11:15 AM
Tony A
John,

I posted a function that managed this a while back (here). It was in response to get the RIGHT n characters from a string but it should give you some syntactical ideas?

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 
July 08, 2008, 11:33 AM
Danny-SRL
John,

Since you don't know the length of your input string you could use a variable length string. See this example:
  
-* File deffunc.fex
DEFINE FUNCTION NOCRLF(INLEN/I3, INDATA/A255) 
TEMP/A255 = STRREP (INLEN,INDATA, 1, HEXBYT(13, 'A1'), 1, ' ',INLEN, TEMP);
NOCRLF/A255V = STRREP(INLEN,TEMP, 1, HEXBYT(10, 'A1'), 1, ' ', INLEN, NOCRLF);
END

DEFINE FILE CAR
MODEL_BODY/A40=MODEL || HEXBYT(13,'A1') || HEXBYT(10,'A1') || BODYTYPE;
END

TABLE FILE CAR
PRINT MODEL_BODY
BY COUNTRY
BY CAR
ON TABLE HOLD 
END
SAVE AS SAVECRLF
!TYPE SAVECRLF.FTM
-RUN
DEFINE FILE HOLD
TEMP/A40=NOCRLF(40, MODEL_BODY);
END
TABLE FILE HOLD
PRINT TEMP
BY COUNTRY
BY CAR
ON TABLE SAVE
END
-RUN 
!TYPE SAVE.FTM



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