Page 1 of 1
memowrit() file type DOS or UNIX
Posted: Mon Feb 14, 2022 8:41 am
by Otto
Dear Crsitobal,
sometimes when I save text with memowrite() the files are stored as UNIX Type files.
I do not find out where I can change that the files are always DOS Type files.
I think I saw inside your fivedit this possibility. Can you please show me where you can change type format with FW source code?
Best regards,
Otto
Re: memowrit() file type DOS or UNIX
Posted: Mon Feb 14, 2022 9:05 am
by Antonio Linares
Dear Otto,
From google:
The main difference isĀ in the line endings for each. Windows uses CR-LF as the line ending in a text file, while linux uses LF and MacOS uses (used?) CR. The upshot of this is that if you save a script file on Windows it will default to CR-LF which will make the script unable to be executed in Linux.
Re: memowrit() file type DOS or UNIX
Posted: Mon Feb 14, 2022 9:12 am
by cnavarro
Dear Otto
PREFERENCES - GENERAL - Convert and Settings - Set EOL CRLF ( or LF or CR )
Re: memowrit() file type DOS or UNIX
Posted: Mon Feb 14, 2022 10:21 am
by Otto
Dear Antonio, dear Cristobal,
Thank you for your help.
As I need this inside my code, do you think strTans() could work?
>Windows uses CR-LF as the line ending in a text file, while linux uses LF
Best regards,
Otto
Re: memowrit() file type DOS or UNIX
Posted: Mon Feb 14, 2022 4:38 pm
by Antonio Linares
Dear Otto,
You can use StrTran( cText, Chr( 13 ) + Chr( 10 ), Chr( 10 ) ) to go from Windows to Linux
but to go from Linux to Windows I think you can not use StrTran() or you will go into an endless loop as it will never stop:
StrTran( cText, Chr( 10 ), Chr( 13 ) + Chr( 10 ) )
So from Linux to Windows you may do:
local aLines := hb_ATokens( cText, LF )
and then create the text:
cText := ""
AEval( aLines, { | cLine | cText += cLine + CRLF } )
Re: memowrit() file type DOS or UNIX
Posted: Mon Feb 14, 2022 4:56 pm
by Otto
Dear Antonio,
Thank you.
As these files are only a few lines, maybe I can
STRTRAN() CRLF to something
then STRTRAN() LF to CRLF
and then something to CRLF.
I will try when I face the next time, a wrong file type.
Best regards,
Otto
Re: memowrit() file type DOS or UNIX
Posted: Wed Feb 16, 2022 10:00 pm
by Jimmy
hi,
i have a "Old" which need CRLF else all is "one line"
i have this working Source which work under Xbase++
Code: Select all | Expand
#include "Directry.ch"
PROCEDURE MAIN()
LOCAL aDir
LOCAL cFile
LOCAL cMemo
LOCAL cOut
LOCAL i,iMax
aDir := Directory("*.PRG")
iMax := LEN(aDir)
FOR i := 1 TO iMax
cFile := aDir[i][F_NAME]
cMemo := MEMOREAD(cFile)
cMemo := StrTran(cMemo,CHR(10),CHR(13)+CHR(10))
cOut := UPPER(cFile)
cOut := StrTran(cOut,".PRG",".PPG") // just to have other Extension
MemoWrit(cOut, cMemo)
NEXT
RETURN
it should also run under harbour