memowrit() file type DOS or UNIX

memowrit() file type DOS or UNIX

Postby Otto » Mon Feb 14, 2022 8:41 am

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: memowrit() file type DOS or UNIX

Postby Antonio Linares » Mon Feb 14, 2022 9:05 am

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: memowrit() file type DOS or UNIX

Postby cnavarro » Mon Feb 14, 2022 9:12 am

Dear Otto
PREFERENCES - GENERAL - Convert and Settings - Set EOL CRLF ( or LF or CR )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: memowrit() file type DOS or UNIX

Postby Otto » Mon Feb 14, 2022 10:21 am

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: memowrit() file type DOS or UNIX

Postby Antonio Linares » Mon Feb 14, 2022 4:38 pm

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 } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: memowrit() file type DOS or UNIX

Postby Otto » Mon Feb 14, 2022 4:56 pm

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: memowrit() file type DOS or UNIX

Postby Jimmy » Wed Feb 16, 2022 10:00 pm

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 view
#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
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 89 guests