Tengo un archivo TXT el cuel contiene esto:
Company........: EMPRESA INVALIDA
Database status: Database is locked
Locked by......:
Date locked....: Agosto 29, 2017
Process name...: Equipment
Message........: You need to wait until the database is released
29/08/2017
17:41:50
All right for: POSADAS SOFTWARE
¿Cómo puedo leerlo y mostrarlo en un MSGINFO, MSGEXCLAMATION ? o sino se puede en uno de esos MSG, entonces que sea presentado en pantalla para que lo lea el usuario.
De antemano gracias por la ayuda.
Leer un archivo TXT
Moderator: Rathinagiri
-
- Posts: 174
- Joined: Mon May 19, 2014 7:43 pm
- DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
- Location: Morelia, Mich. México
- Contact:
Leer un archivo TXT
Cordialmente
POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
Re: Leer un archivo TXT
Jorge,
MEMOREAD() te puede servir perfectamente.
Pero si necesitas convertir cada una de las líneas en una cadena que manipular posteriormente, puedes manejar el fichero a bajo nivel.
Por ejemplo, esta función te daría como resultado hasta 20 líneas del fichero .TXT
-------------------------------
MEMOREAD () can serve you perfectly.
But if you need to convert each of the lines into a string to be manipulated later, you can handle the file at a low level.
For example, this function would result in up to 20 lines of the .TXT file.
-------------------------------
(No lo he probado, pero con un poco de suerte a lo mejor funciona )
MEMOREAD() te puede servir perfectamente.
Pero si necesitas convertir cada una de las líneas en una cadena que manipular posteriormente, puedes manejar el fichero a bajo nivel.
Por ejemplo, esta función te daría como resultado hasta 20 líneas del fichero .TXT
-------------------------------
MEMOREAD () can serve you perfectly.
But if you need to convert each of the lines into a string to be manipulated later, you can handle the file at a low level.
For example, this function would result in up to 20 lines of the .TXT file.
-------------------------------
Code: Select all
PUBLIC CADENA:=ARRAY(20)
FUNCTION LEOTXT()
LOCAL CONTA,NFICHE,CARACT
FOR CONTA:=1 TO 20 ; CADENA[CONTA]:="" ; NEXT
CONTA:=1
NFICHE:=FOPEN("FICHE.TXT")
IF NFICHE<0
*** PONER MENSAJE DE ERROR ***
RETURN
ENDIF
WHILE .T.
CARACT:=FREADSTR(NFICHE,1)
IF CARACT=="" ; EXIT ; ENDIF
*** ESTO ES PARA DETECTAR EL FINAL DE CADA LINEA ***
IF ASC(CARACT)==10 .OR. ASC(CARACT)==13
CARACT:=FREADSTR(NFICHE,1)
CONTA+=1
IF CONTA>20 ; EXIT ; ENDIF
LOOP
ENDIF
CADENA[CONTA]:=CADENA[CONTA]+CARACT
END
FCLOSE(NFICHE)
RETURN
I get by with a little help from my friends
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Leer un archivo TXT
This particular function will return all the lines as an array of strings.
Code: Select all
aStrings := HB_ATOKENS( MEMOREAD( cTxtFile ), CRLF )
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Leer un archivo TXT
Sometimes a simple code can achieve the work of many complex codesRathinagiri wrote: ↑Wed Aug 30, 2017 9:41 am This particular function will return all the lines as an array of strings.
Code: Select all
aStrings := HB_ATOKENS( MEMOREAD( cTxtFile ), CRLF )
Regards,
Anand
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Leer un archivo TXT
Normally I try to write my own code. However, this function was introduced to me by Esgici in his ComboSearchBox sample. From then on, I try to search for pre-defined functions.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.