Page 1 of 1

Generating TXT Files with Specific Delimiters in Visual LANSA

Posted: Fri Sep 19, 2025 4:32 am
by OmarMonroy
Hello everyone,

Is it possible to generate TXT files using a specific delimiter (|) with a built-in function in Visual LANSA and then retrieve them into my web application? I would appreciate any guidance or examples on how to implement this.

Thank you!

Re: Generating TXT Files with Specific Delimiters in Visual LANSA

Posted: Fri Sep 19, 2025 4:03 pm
by kno_dk
Hi.

this is what I use when I want to create a log file.

Define_Com Class(#prim_dc.UnicodeString) Name(#CarriageReturn)
Define_Com Class(#prim_dc.UnicodeString) Name(#LineFeed)
#LineFeed := (10).AsUnicodeString
#CarriageReturn := (13).AsUnicodeString

#Logtxt01 += 'id_token: ' + #id_token + #CarriageReturn.AsNativeString + #LineFeed.asnativestring

Change Field(#OPTIONS) To('''WRITE notrim Text lineTerminator= CRLF CodePage=1208''')

#FILEname := '/LANSA_DCXPGMLIB/tmp/erc/' + *guid + '.txt'
Use Builtin(STM_FILE_OPEN) With_Args(#FILEname #OPTIONS) To_Get(#FILENO #RETNCODE)
*
#string01 := #Logtxt01.AsNativeString
#string02 := #Logtxt02.AsNativeString
#string03 := #Logtxt03.AsNativeString
#string04 := #Logtxt04.AsNativeString
#string05 := #Logtxt05.AsNativeString

Use Builtin(STM_FILE_WRITE) With_Args(#FILENO #string01 #string02 #string03 #string04 #string05) To_Get(#RETNCODE)
*
Use Builtin(STM_FILE_CLOSE) With_Args(#FILENO)

Re: Generating TXT Files with Specific Delimiters in Visual LANSA

Posted: Fri Oct 03, 2025 2:04 am
by OmarMonroy
Thank you very much for the support, it worked perfectly.

Re: Generating TXT Files with Specific Delimiters in Visual LANSA

Posted: Tue Nov 25, 2025 7:15 am
by stevelee67
in an RDMLX world, there is an additional option of using the #PRIM_IOC.xxx primitives. they're a little more complicated to use but they get the job done.
you can also use #XPRIM_FILE objects to do a lot of stuff.

honestly, the BIFs work just fine and are probably more familiar. but if you need something complex you can look in to them.

if you are looking for a delimited file, you can also use the TRANSFORM_LIST BIF (as long as your cool with either comma or tab delimiters). if you need things in unicode, use the "U" formats (e.g., AU instead of A for comma delimited or TU for tab delimited). there are ways to keep the file open while you're writing to allow for a significant amount of flexibility. it is kinda slow, so if you're dumping big batches of data, the STM_FILE BIFs or #PRIM_IOC objects are your better option.