Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.lang.xharbour / fopen(), freadstr()...

SubjectAuthor
* fopen(), freadstr()...timepro timesheet
`* fopen(), freadstr()...poopall
 `* fopen(), freadstr()...timepro timesheet
  `* fopen(), freadstr()...Michael Hagl
   `* fopen(), freadstr()...timepro timesheet
    `* fopen(), freadstr()...Michael Hagl
     `* fopen(), freadstr()...timepro timesheet
      `* fopen(), freadstr()...Michael Hagl
       +- fopen(), freadstr()...PARESH VALIA
       +- fopen(), freadstr()...timepro timesheet
       `* fopen(), freadstr()...FP
        `- fopen(), freadstr()...Dan

1
fopen(), freadstr()...

<af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10429&group=comp.lang.xharbour#10429

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:ac8:5a84:: with SMTP id c4mr39625151qtc.565.1641206550529;
Mon, 03 Jan 2022 02:42:30 -0800 (PST)
X-Received: by 2002:ae9:efc1:: with SMTP id d184mr31805449qkg.707.1641206550399;
Mon, 03 Jan 2022 02:42:30 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Mon, 3 Jan 2022 02:42:30 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=2401:4900:1c20:12b4:5cc2:ee56:2ad5:da28;
posting-account=jZAeNwoAAABYWjMRM-FfqKkHfC3Iph0l
NNTP-Posting-Host: 2401:4900:1c20:12b4:5cc2:ee56:2ad5:da28
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
Subject: fopen(), freadstr()...
From: timecost...@gmail.com (timepro timesheet)
Injection-Date: Mon, 03 Jan 2022 10:42:30 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: timepro timesheet - Mon, 3 Jan 2022 10:42 UTC

existing file name: custbill.txt
lines: 104 (each line varying no. of characters).
( <cr> after end of each line )
there may be blank lines too.
-with fopen(),freadstr() how to assign the text of each line (lines 1 to 104) to each new variable.

e.g.
textline1=the full text/words of the 1st line in custbill.txt
textline2=the full text/characters of the 2nd line
....
textline26=the full text/words of the 26th line
....
textline104=the full text/words of the 104th line in custbill.txt

thank you.

Re: fopen(), freadstr()...

<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10432&group=comp.lang.xharbour#10432

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:622a:181c:: with SMTP id t28mr40934819qtc.633.1641302432649;
Tue, 04 Jan 2022 05:20:32 -0800 (PST)
X-Received: by 2002:a05:620a:4489:: with SMTP id x9mr34427092qkp.634.1641302432317;
Tue, 04 Jan 2022 05:20:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Tue, 4 Jan 2022 05:20:32 -0800 (PST)
In-Reply-To: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=14.202.219.18; posting-account=zx0oKAkAAABMkjQR74hmeFvHN7cev7io
NNTP-Posting-Host: 14.202.219.18
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: lawrence...@gmail.com (poopall)
Injection-Date: Tue, 04 Jan 2022 13:20:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: poopall - Tue, 4 Jan 2022 13:20 UTC

On Monday, 3 January 2022 at 9:42:31 pm UTC+11, timec...@gmail.com wrote:
> existing file name: custbill.txt
> lines: 104 (each line varying no. of characters).
> ( <cr> after end of each line )
> there may be blank lines too.
> -with fopen(),freadstr() how to assign the text of each line (lines 1 to 104) to each new variable.
>
> e.g.
> textline1=the full text/words of the 1st line in custbill.txt
> textline2=the full text/characters of the 2nd line
> ...
> textline26=the full text/words of the 26th line
> ...
> textline104=the full text/words of the 104th line in custbill.txt
>
> thank you.
Why would you not assign each line to an element in an array

Re: fopen(), freadstr()...

<cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10433&group=comp.lang.xharbour#10433

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:111c:: with SMTP id o28mr34770960qkk.328.1641308683146;
Tue, 04 Jan 2022 07:04:43 -0800 (PST)
X-Received: by 2002:a05:620a:2586:: with SMTP id x6mr36824030qko.260.1641308682578;
Tue, 04 Jan 2022 07:04:42 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Tue, 4 Jan 2022 07:04:42 -0800 (PST)
In-Reply-To: <4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2401:4900:1c20:12b4:d104:3b4c:d553:a1f0;
posting-account=jZAeNwoAAABYWjMRM-FfqKkHfC3Iph0l
NNTP-Posting-Host: 2401:4900:1c20:12b4:d104:3b4c:d553:a1f0
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com> <4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: timecost...@gmail.com (timepro timesheet)
Injection-Date: Tue, 04 Jan 2022 15:04:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: timepro timesheet - Tue, 4 Jan 2022 15:04 UTC

On Tuesday, January 4, 2022 at 6:50:33 PM UTC+5:30, poopall wrote:
> On Monday, 3 January 2022 at 9:42:31 pm UTC+11, timec...@gmail.com wrote:
> > existing file name: custbill.txt
> > lines: 104 (each line varying no. of characters).
> > ( <cr> after end of each line )
> > there may be blank lines too.
> > -with fopen(),freadstr() how to assign the text of each line (lines 1 to 104) to each new variable.
> >
> > e.g.
> > textline1=the full text/words of the 1st line in custbill.txt
> > textline2=the full text/characters of the 2nd line
> > ...
> > textline26=the full text/words of the 26th line
> > ...
> > textline104=the full text/words of the 104th line in custbill.txt
> >
> > thank you.
> Why would you not assign each line to an element in an array

poopall:

the xxxxx.txt file is created by the user. (i wouldn't know the contents of the file.)
line 1 will have the user defined/typed 'font name'
line 2 will have the user defined 'font size'
line 87 will have the 'style'
....
line 104 will...

in the bill print module of my app, i have to read each line and assign that as the cosmetics (font,size,...)
i use pagescript32 functions for my output design.
e.g.
pssetfont('fontname' will be line1 of xxx.txt, 'style' will be line 2, 'size' will be line 87...,xxx,yyy)
after getting the values, it would process as pssetfont('arial',1,11,....)
assigning to a variable or element in an array...i can code either way.

*
i just do not know the syntax on how to read each line from the filename.txt.
what is the syntax to read each line from filename.txt and assign them to a variable/array element.
*

thank you

Re: fopen(), freadstr()...

<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10434&group=comp.lang.xharbour#10434

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:dcf:: with SMTP id 15mr46320500qvt.47.1641312080829;
Tue, 04 Jan 2022 08:01:20 -0800 (PST)
X-Received: by 2002:a05:6214:27ea:: with SMTP id jt10mr44673271qvb.49.1641312080597;
Tue, 04 Jan 2022 08:01:20 -0800 (PST)
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Tue, 4 Jan 2022 08:01:20 -0800 (PST)
In-Reply-To: <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.151.237.2; posting-account=V7lAIgoAAAC3DUcIU4p9S6DraPJfG7Az
NNTP-Posting-Host: 80.151.237.2
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: inf...@hagl.de (Michael Hagl)
Injection-Date: Tue, 04 Jan 2022 16:01:20 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 136
 by: Michael Hagl - Tue, 4 Jan 2022 16:01 UTC

timec...@gmail.com schrieb am Dienstag, 4. Januar 2022 um 16:04:43 UTC+1:
> On Tuesday, January 4, 2022 at 6:50:33 PM UTC+5:30, poopall wrote:
> > On Monday, 3 January 2022 at 9:42:31 pm UTC+11, timec...@gmail.com wrote:
> > > existing file name: custbill.txt
> > > lines: 104 (each line varying no. of characters).
> > > ( <cr> after end of each line )
> > > there may be blank lines too.
> > > -with fopen(),freadstr() how to assign the text of each line (lines 1 to 104) to each new variable.
> > >
> > > e.g.
> > > textline1=the full text/words of the 1st line in custbill.txt
> > > textline2=the full text/characters of the 2nd line
> > > ...
> > > textline26=the full text/words of the 26th line
> > > ...
> > > textline104=the full text/words of the 104th line in custbill.txt
> > >
> > > thank you.
> > Why would you not assign each line to an element in an array
> poopall:
>
> the xxxxx.txt file is created by the user. (i wouldn't know the contents of the file.)
> line 1 will have the user defined/typed 'font name'
> line 2 will have the user defined 'font size'
> line 87 will have the 'style'
> ...
> line 104 will...
>
> in the bill print module of my app, i have to read each line and assign that as the cosmetics (font,size,...)
> i use pagescript32 functions for my output design.
> e.g.
> pssetfont('fontname' will be line1 of xxx.txt, 'style' will be line 2, 'size' will be line 87...,xxx,yyy)
> after getting the values, it would process as pssetfont('arial',1,11,....)
> assigning to a variable or element in an array...i can code either way.
>
> *
> i just do not know the syntax on how to read each line from the filename.txt.
> what is the syntax to read each line from filename.txt and assign them to a variable/array element.
> *
>
> thank you

Hi,

you can do:

aTextArr := TxtFile2Array("custbill.txt")

****************************************************************************************************************************
FUNCTION TxtFile2Array(cDatei,nALen,nCLen,lMax,lKommFilter,aRest,cTestLeft,bFilter,lLtrim,lAnsiTest)
LOCAL i, x
LOCAL hDatei
LOCAL lOk := .t.
DEFAULT lKommFilter TO .f.
DEFAULT lLtrim TO .t.
DEFAULT lAnsiTest TO .t.
IF !File(cDatei)
lOk := .f.
ENDIF
DEFAULT aRest TO {}
IF !(nAlen == NIL)
aRest := ARRAY(nALen)
ENDIF
IF lMax == NIL
lMax := .f.
ENDIF

IF lOk
i := 0
hDatei := FOpen(cDatei)

IF hDatei > 0
DO WHILE !FEof(hDatei)
i ++
x := FReadLine(hDatei)
IF AllTrim(x) == Chr(26)
EXIT
ENDIF
IF Right(x,1) == Chr(26)
x := Left(x,Len(x)-1)
ENDIF

IF !Empty(cTestLeft)
IF !(Left(x,Len(cTestLeft)) == cTestLeft)
LOOP
ENDIF
ENDIF

IF !Empty(bFilter)
IF !Eval(bFilter,x)
LOOP
ENDIF
ENDIF

IF lKommFilter .and. Left(x,2) == "//"
LOOP
ENDIF
IF lAnsiTest .and. IsAnsiString(x)
x := Ansi2Ascii(x)
ENDIF
IF nAlen == NIL
AAdd(aRest,Iif(lLtrim,Formkey(x,nCLen),x))
ELSE
IF i > nALen
EXIT
ENDIF
aRest[i] := Iif(lLtrim,Formkey(x,nCLen),x)
ENDIF
ENDDO
FClose(hDatei)
ENDIF
IF !(nAlen == NIL)
IF i < nALen
lOk := .f.
ENDIF
ENDIF
ENDIF
IF !lOk
IF nALen == NIL
nALen := Len(aRest)
ENDIF
FOR i := 1 TO nAlen
IF aRest[i] == NIL
aRest[i] := Space(nCLen)
ENDIF
NEXT i
ENDIF
IF lMax
nCLen := AmaxStrLen(aRest)
nALen := Len(aRest)
FOR i := 1 TO nAlen
aRest[i] := Iif(lLtrim,Formkey(aRest[i],nCLen),Left(aRest[i],nCLen))
NEXT i
ENDIF
RETURN aRest

Re: fopen(), freadstr()...

<9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10439&group=comp.lang.xharbour#10439

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:3187:: with SMTP id bi7mr38406630qkb.534.1641360149542;
Tue, 04 Jan 2022 21:22:29 -0800 (PST)
X-Received: by 2002:ac8:5e0f:: with SMTP id h15mr48030476qtx.123.1641360149336;
Tue, 04 Jan 2022 21:22:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Tue, 4 Jan 2022 21:22:28 -0800 (PST)
In-Reply-To: <bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2401:4900:1c20:12b4:2812:51dd:52f2:e964;
posting-account=jZAeNwoAAABYWjMRM-FfqKkHfC3Iph0l
NNTP-Posting-Host: 2401:4900:1c20:12b4:2812:51dd:52f2:e964
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: timecost...@gmail.com (timepro timesheet)
Injection-Date: Wed, 05 Jan 2022 05:22:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 149
 by: timepro timesheet - Wed, 5 Jan 2022 05:22 UTC

On Tuesday, January 4, 2022 at 9:31:21 PM UTC+5:30, in...@hagl.de wrote:
> timec...@gmail.com schrieb am Dienstag, 4. Januar 2022 um 16:04:43 UTC+1:
> > On Tuesday, January 4, 2022 at 6:50:33 PM UTC+5:30, poopall wrote:
> > > On Monday, 3 January 2022 at 9:42:31 pm UTC+11, timec...@gmail.com wrote:
> > > > existing file name: custbill.txt
> > > > lines: 104 (each line varying no. of characters).
> > > > ( <cr> after end of each line )
> > > > there may be blank lines too.
> > > > -with fopen(),freadstr() how to assign the text of each line (lines 1 to 104) to each new variable.
> > > >
> > > > e.g.
> > > > textline1=the full text/words of the 1st line in custbill.txt
> > > > textline2=the full text/characters of the 2nd line
> > > > ...
> > > > textline26=the full text/words of the 26th line
> > > > ...
> > > > textline104=the full text/words of the 104th line in custbill.txt
> > > >
> > > > thank you.
> > > Why would you not assign each line to an element in an array
> > poopall:
> >
> > the xxxxx.txt file is created by the user. (i wouldn't know the contents of the file.)
> > line 1 will have the user defined/typed 'font name'
> > line 2 will have the user defined 'font size'
> > line 87 will have the 'style'
> > ...
> > line 104 will...
> >
> > in the bill print module of my app, i have to read each line and assign that as the cosmetics (font,size,...)
> > i use pagescript32 functions for my output design.
> > e.g.
> > pssetfont('fontname' will be line1 of xxx.txt, 'style' will be line 2, 'size' will be line 87...,xxx,yyy)
> > after getting the values, it would process as pssetfont('arial',1,11,....)
> > assigning to a variable or element in an array...i can code either way.
> >
> > *
> > i just do not know the syntax on how to read each line from the filename.txt.
> > what is the syntax to read each line from filename.txt and assign them to a variable/array element.
> > *
> >
> > thank you
> Hi,
>
> you can do:
>
> aTextArr := TxtFile2Array("custbill.txt")
>
> ****************************************************************************************************************************
> FUNCTION TxtFile2Array(cDatei,nALen,nCLen,lMax,lKommFilter,aRest,cTestLeft,bFilter,lLtrim,lAnsiTest)
> LOCAL i, x
> LOCAL hDatei
> LOCAL lOk := .t.
> DEFAULT lKommFilter TO .f.
> DEFAULT lLtrim TO .t.
> DEFAULT lAnsiTest TO .t.
> IF !File(cDatei)
> lOk := .f.
> ENDIF
> DEFAULT aRest TO {}
> IF !(nAlen == NIL)
> aRest := ARRAY(nALen)
> ENDIF
> IF lMax == NIL
> lMax := .f.
> ENDIF
>
> IF lOk
> i := 0
> hDatei := FOpen(cDatei)
>
> IF hDatei > 0
> DO WHILE !FEof(hDatei)
> i ++
> x := FReadLine(hDatei)
> IF AllTrim(x) == Chr(26)
> EXIT
> ENDIF
> IF Right(x,1) == Chr(26)
> x := Left(x,Len(x)-1)
> ENDIF
>
> IF !Empty(cTestLeft)
> IF !(Left(x,Len(cTestLeft)) == cTestLeft)
> LOOP
> ENDIF
> ENDIF
>
> IF !Empty(bFilter)
> IF !Eval(bFilter,x)
> LOOP
> ENDIF
> ENDIF
>
> IF lKommFilter .and. Left(x,2) == "//"
> LOOP
> ENDIF
> IF lAnsiTest .and. IsAnsiString(x)
> x := Ansi2Ascii(x)
> ENDIF
> IF nAlen == NIL
> AAdd(aRest,Iif(lLtrim,Formkey(x,nCLen),x))
> ELSE
> IF i > nALen
> EXIT
> ENDIF
> aRest[i] := Iif(lLtrim,Formkey(x,nCLen),x)
> ENDIF
> ENDDO
> FClose(hDatei)
> ENDIF
> IF !(nAlen == NIL)
> IF i < nALen
> lOk := .f.
> ENDIF
> ENDIF
> ENDIF
> IF !lOk
> IF nALen == NIL
> nALen := Len(aRest)
> ENDIF
> FOR i := 1 TO nAlen
> IF aRest[i] == NIL
> aRest[i] := Space(nCLen)
> ENDIF
> NEXT i
> ENDIF
> IF lMax
> nCLen := AmaxStrLen(aRest)
> nALen := Len(aRest)
> FOR i := 1 TO nAlen
> aRest[i] := Iif(lLtrim,Formkey(aRest[i],nCLen),Left(aRest[i],nCLen))
> NEXT i
> ENDIF
> RETURN aRest

looks like a 'ready-to-use' function
thank you: in...@hagl.de
:few queries please,
instead of 'DEFAULT lKommFilter TO .f. ' , if i code 'lKommFilter=.f.' , will anything differ?
also, instead of 'DEFAULT aRest TO {} ', i code 'priv arest[0]; afill(arest,''")' ...
you have not incorporated checking for the <cr>, or is it not required?

your code:
'aTextArr := TxtFile2Array("custbill.txt")
FUNCTION TxtFile2Array(cDatei,nALen,nCLen,lMax,lKommFilter,aRest,cTestLeft,bFilter,lLtrim,lAnsiTest) '
-but TxtFile2Array("custbill.txt") is sending just 1 parameter to Txtfile2array() - the filename.

regards

Re: fopen(), freadstr()...

<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10440&group=comp.lang.xharbour#10440

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:212d:: with SMTP id r13mr8888500qvc.63.1641369523449;
Tue, 04 Jan 2022 23:58:43 -0800 (PST)
X-Received: by 2002:ac8:5c09:: with SMTP id i9mr44441998qti.243.1641369523130;
Tue, 04 Jan 2022 23:58:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Tue, 4 Jan 2022 23:58:42 -0800 (PST)
In-Reply-To: <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.151.237.2; posting-account=V7lAIgoAAAC3DUcIU4p9S6DraPJfG7Az
NNTP-Posting-Host: 80.151.237.2
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com> <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: inf...@hagl.de (Michael Hagl)
Injection-Date: Wed, 05 Jan 2022 07:58:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 227
 by: Michael Hagl - Wed, 5 Jan 2022 07:58 UTC

timec...@gmail.com schrieb am Mittwoch, 5. Januar 2022 um 06:22:30 UTC+1:
> On Tuesday, January 4, 2022 at 9:31:21 PM UTC+5:30, in...@hagl.de wrote:
> > timec...@gmail.com schrieb am Dienstag, 4. Januar 2022 um 16:04:43 UTC+1:
> > > On Tuesday, January 4, 2022 at 6:50:33 PM UTC+5:30, poopall wrote:
> > > > On Monday, 3 January 2022 at 9:42:31 pm UTC+11, timec...@gmail.com wrote:
> > > > > existing file name: custbill.txt
> > > > > lines: 104 (each line varying no. of characters).
> > > > > ( <cr> after end of each line )
> > > > > there may be blank lines too.
> > > > > -with fopen(),freadstr() how to assign the text of each line (lines 1 to 104) to each new variable.
> > > > >
> > > > > e.g.
> > > > > textline1=the full text/words of the 1st line in custbill.txt
> > > > > textline2=the full text/characters of the 2nd line
> > > > > ...
> > > > > textline26=the full text/words of the 26th line
> > > > > ...
> > > > > textline104=the full text/words of the 104th line in custbill.txt
> > > > >
> > > > > thank you.
> > > > Why would you not assign each line to an element in an array
> > > poopall:
> > >
> > > the xxxxx.txt file is created by the user. (i wouldn't know the contents of the file.)
> > > line 1 will have the user defined/typed 'font name'
> > > line 2 will have the user defined 'font size'
> > > line 87 will have the 'style'
> > > ...
> > > line 104 will...
> > >
> > > in the bill print module of my app, i have to read each line and assign that as the cosmetics (font,size,...)
> > > i use pagescript32 functions for my output design.
> > > e.g.
> > > pssetfont('fontname' will be line1 of xxx.txt, 'style' will be line 2, 'size' will be line 87...,xxx,yyy)
> > > after getting the values, it would process as pssetfont('arial',1,11,....)
> > > assigning to a variable or element in an array...i can code either way.
> > >
> > > *
> > > i just do not know the syntax on how to read each line from the filename.txt.
> > > what is the syntax to read each line from filename.txt and assign them to a variable/array element.
> > > *
> > >
> > > thank you
> > Hi,
> >
> > you can do:
> >
> > aTextArr := TxtFile2Array("custbill.txt")
> >
> > ****************************************************************************************************************************
> > FUNCTION TxtFile2Array(cDatei,nALen,nCLen,lMax,lKommFilter,aRest,cTestLeft,bFilter,lLtrim,lAnsiTest)
> > LOCAL i, x
> > LOCAL hDatei
> > LOCAL lOk := .t.
> > DEFAULT lKommFilter TO .f.
> > DEFAULT lLtrim TO .t.
> > DEFAULT lAnsiTest TO .t.
> > IF !File(cDatei)
> > lOk := .f.
> > ENDIF
> > DEFAULT aRest TO {}
> > IF !(nAlen == NIL)
> > aRest := ARRAY(nALen)
> > ENDIF
> > IF lMax == NIL
> > lMax := .f.
> > ENDIF
> >
> > IF lOk
> > i := 0
> > hDatei := FOpen(cDatei)
> >
> > IF hDatei > 0
> > DO WHILE !FEof(hDatei)
> > i ++
> > x := FReadLine(hDatei)
> > IF AllTrim(x) == Chr(26)
> > EXIT
> > ENDIF
> > IF Right(x,1) == Chr(26)
> > x := Left(x,Len(x)-1)
> > ENDIF
> >
> > IF !Empty(cTestLeft)
> > IF !(Left(x,Len(cTestLeft)) == cTestLeft)
> > LOOP
> > ENDIF
> > ENDIF
> >
> > IF !Empty(bFilter)
> > IF !Eval(bFilter,x)
> > LOOP
> > ENDIF
> > ENDIF
> >
> > IF lKommFilter .and. Left(x,2) == "//"
> > LOOP
> > ENDIF
> > IF lAnsiTest .and. IsAnsiString(x)
> > x := Ansi2Ascii(x)
> > ENDIF
> > IF nAlen == NIL
> > AAdd(aRest,Iif(lLtrim,Formkey(x,nCLen),x))
> > ELSE
> > IF i > nALen
> > EXIT
> > ENDIF
> > aRest[i] := Iif(lLtrim,Formkey(x,nCLen),x)
> > ENDIF
> > ENDDO
> > FClose(hDatei)
> > ENDIF
> > IF !(nAlen == NIL)
> > IF i < nALen
> > lOk := .f.
> > ENDIF
> > ENDIF
> > ENDIF
> > IF !lOk
> > IF nALen == NIL
> > nALen := Len(aRest)
> > ENDIF
> > FOR i := 1 TO nAlen
> > IF aRest[i] == NIL
> > aRest[i] := Space(nCLen)
> > ENDIF
> > NEXT i
> > ENDIF
> > IF lMax
> > nCLen := AmaxStrLen(aRest)
> > nALen := Len(aRest)
> > FOR i := 1 TO nAlen
> > aRest[i] := Iif(lLtrim,Formkey(aRest[i],nCLen),Left(aRest[i],nCLen))
> > NEXT i
> > ENDIF
> > RETURN aRest
> looks like a 'ready-to-use' function
> thank you: in...@hagl.de
>
> :few queries please,
> instead of 'DEFAULT lKommFilter TO .f. ' , if i code 'lKommFilter=.f.' , will anything differ?
> also, instead of 'DEFAULT aRest TO {} ', i code 'priv arest[0]; afill(arest,''")' ...
> you have not incorporated checking for the <cr>, or is it not required?
>
> your code:
> 'aTextArr := TxtFile2Array("custbill.txt")
> FUNCTION TxtFile2Array(cDatei,nALen,nCLen,lMax,lKommFilter,aRest,cTestLeft,bFilter,lLtrim,lAnsiTest) '
> -but TxtFile2Array("custbill.txt") is sending just 1 parameter to Txtfile2array() - the filename.
>
> regards

Hi,

this is a short version of function and I forgot the following functions.
********************************************
FUNCTION TxtFileToArray(cDatei)
LOCAL i, x, hDatei
LOCAL aRest := {}
IF File(cDatei)
i := 0
hDatei := FOpen(cDatei)
IF hDatei > 0
DO WHILE !FEof(hDatei)
i ++
x := FReadLine(hDatei)
IF AllTrim(x) == Chr(26)
EXIT
ENDIF
IF Right(x,1) == Chr(26)
x := Left(x,Len(x)-1)
ENDIF
AAdd(aRest,Iif(lLtrim,Formkey(x,nCLen),x))
ENDDO
FClose(hDatei)
ENDIF
ENDIF
RETURN aRest

*****************
FUNCTION FReadLine(nHandle,cEol)
LOCAL cLine
DEFAULT cEol TO Chr(10)
HB_FreadLine(nHandle,@cLine,cEol)
IF Right(cLine,1) == Chr(13)
RETURN Left(cLine,Len(cLine)-1)
ENDIF
RETURN cLine
****************************************
**********************************************************************
/* Usage: fbof(handle) -> lStatus feof(handle) -> lStatus
Params: int handle - A handle returned from a previous call to
fopen() or fcreate().
Returns:
TRUE if the file pointer is at the beginning (fbof) or at
the end (feof) of the file associated with <handle>, FALSE if not
*/
FUNCTION FEof(nHandle)
************************
LOCAL nPos := FSeek(nHandle,0,1)
LOCAL nBot := FSeek(nHandle,0,2)
LOCAL lOk := (nPos >= nBot)
FSeek(nHandle,nPos,0)
RETURN lOk
*************************************************************************
FUNCTION fBof(nHandle)
**********************
LOCAL nPos := FSeek(nHandle,0,1)
LOCAL lOk := (nPos == 0)
RETURN lOk
******************************************************************************************

But you can also use Memoread() Function:
***********************************************************************
FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen)
LOCAL cText, nLines, i
LOCAL aRest := {}
DEFAULT nMaxLineLen TO 250
IF File(cDatei)
cText := MemoRead(cDatei)
nLines := MlCount(cText,nMaxLineLen)
ASize(aRest,nLines)
FOR i := 1 TO nLines
aRest[i] := Memoline(cText,nMaxLineLen,i)
NEXT
ENDIF
RETURN aRest

Re: fopen(), freadstr()...

<14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10442&group=comp.lang.xharbour#10442

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:6214:c21:: with SMTP id a1mr49170961qvd.100.1641375085669;
Wed, 05 Jan 2022 01:31:25 -0800 (PST)
X-Received: by 2002:a05:6214:2aa1:: with SMTP id js1mr49375009qvb.27.1641375085564;
Wed, 05 Jan 2022 01:31:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Wed, 5 Jan 2022 01:31:25 -0800 (PST)
In-Reply-To: <0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2401:4900:1c20:5427:c5a4:5ec1:143d:5a42;
posting-account=jZAeNwoAAABYWjMRM-FfqKkHfC3Iph0l
NNTP-Posting-Host: 2401:4900:1c20:5427:c5a4:5ec1:143d:5a42
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com> <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: timecost...@gmail.com (timepro timesheet)
Injection-Date: Wed, 05 Jan 2022 09:31:25 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 26
 by: timepro timesheet - Wed, 5 Jan 2022 09:31 UTC

> But you can also use Memoread() Function:
> ***********************************************************************
> FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen)
> LOCAL cText, nLines, i
> LOCAL aRest := {}
> DEFAULT nMaxLineLen TO 250
> IF File(cDatei)
> cText := MemoRead(cDatei)
> nLines := MlCount(cText,nMaxLineLen)
> ASize(aRest,nLines)
> FOR i := 1 TO nLines
> aRest[i] := Memoline(cText,nMaxLineLen,i)
> NEXT
> ENDIF
> RETURN aRest

thank you in...@hagl.de

FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen) was just what i was looking for.
tested it, works ok. only 13 lines of code (less is more).

but, how to determine the no. of lines in the/any .txt file.
(your e.g. DEFAULT nMaxLineLen TO 250 ) my users may have more/less no. of lines.
btw: i had never used Memoread,Mlcount,MemoLine till now.

regards

Re: fopen(), freadstr()...

<eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10443&group=comp.lang.xharbour#10443

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:ac8:5f47:: with SMTP id y7mr47496545qta.342.1641377979504;
Wed, 05 Jan 2022 02:19:39 -0800 (PST)
X-Received: by 2002:ac8:5e0f:: with SMTP id h15mr48640028qtx.123.1641377979256;
Wed, 05 Jan 2022 02:19:39 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Wed, 5 Jan 2022 02:19:39 -0800 (PST)
In-Reply-To: <14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.151.237.2; posting-account=V7lAIgoAAAC3DUcIU4p9S6DraPJfG7Az
NNTP-Posting-Host: 80.151.237.2
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com> <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com> <14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: inf...@hagl.de (Michael Hagl)
Injection-Date: Wed, 05 Jan 2022 10:19:39 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 73
 by: Michael Hagl - Wed, 5 Jan 2022 10:19 UTC

timec...@gmail.com schrieb am Mittwoch, 5. Januar 2022 um 10:31:26 UTC+1:
> > But you can also use Memoread() Function:
> > ***********************************************************************
> > FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen)
> > LOCAL cText, nLines, i
> > LOCAL aRest := {}
> > DEFAULT nMaxLineLen TO 250
> > IF File(cDatei)
> > cText := MemoRead(cDatei)
> > nLines := MlCount(cText,nMaxLineLen)
> > ASize(aRest,nLines)
> > FOR i := 1 TO nLines
> > aRest[i] := Memoline(cText,nMaxLineLen,i)
> > NEXT
> > ENDIF
> > RETURN aRest
> thank you in...@hagl.de
>
> FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen) was just what i was looking for.
> tested it, works ok. only 13 lines of code (less is more).
>
> but, how to determine the no. of lines in the/any .txt file.
> (your e.g. DEFAULT nMaxLineLen TO 250 ) my users may have more/less no. of lines.
> btw: i had never used Memoread,Mlcount,MemoLine till now.
>
> regards

Hi,
> but, how to determine the no. of lines in the/any .txt file.
I dont undertand.
MlCount(cText,nMaxLineLen,,,iif(nMaxLineLen>254,.t.,.f.)) returns the number of lines in the text file.

nMaxLineLen is max length of a text line. You should set it higher than the length of the longest line. You can set it to 1000 or bigger, but when set higher than 254 you have to set the fifth param to .t.

Do you not have a function description for xHb?
***************************************************************************************************
MLCount( <cString> , ;
[<nLineLen>] , ;
[<nTabSize>] , ;
[<lWrap>] , ;
[<lLongLines>] ) --> nLineCount

Arguments
<cString>
A character string or memo field to be counted. It can be a formatted text string that includes Tab and Hard/Soft carriage return characters.
<nLineLen>
A numeric value specifying the number of characters per line. It is usually a value between 4 and 254. If <nLineLen> is larger than 254 characters, parameter <lLongLines> must be set to .T. (true). The default value for <nLineLen> is 79.
<nTabSize>
A numeric value specifying the number of blank spaces the Tab character should be expanded to. It defaults to 4 blank spaces.
<lWrap>
A logical value indicating if word wrapping should be applied to <cString> when lines are counted. The default value is .T. (true), resulting in text lines being counted that contain whole words only. When a word does not fit entirely to the end of a text line, it is wrapped to the next text line. Passing .F. (false) for this parameter turns word wrapping off so that only lines ending with a hard carriage return are counted.
<lLongLines>
This parameter defaults to .F. (false). It must be

Michael Hagl

Re: fopen(), freadstr()...

<b3b819ae-f3cf-4333-8008-af7da7b9100fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10444&group=comp.lang.xharbour#10444

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:a05:: with SMTP id i5mr38443722qka.274.1641380872633;
Wed, 05 Jan 2022 03:07:52 -0800 (PST)
X-Received: by 2002:ae9:e809:: with SMTP id a9mr36394925qkg.771.1641380872453;
Wed, 05 Jan 2022 03:07:52 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Wed, 5 Jan 2022 03:07:52 -0800 (PST)
In-Reply-To: <eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2401:4900:1c20:5427:c5a4:5ec1:143d:5a42;
posting-account=TQ3r0woAAABpjOD3G10Mm_gh_OqPDkPo
NNTP-Posting-Host: 2401:4900:1c20:5427:c5a4:5ec1:143d:5a42
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com> <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com> <14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
<eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b3b819ae-f3cf-4333-8008-af7da7b9100fn@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: valiapar...@gmail.com (PARESH VALIA)
Injection-Date: Wed, 05 Jan 2022 11:07:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 95
 by: PARESH VALIA - Wed, 5 Jan 2022 11:07 UTC

On Wednesday, 5 January 2022 at 15:49:40 UTC+5:30, in...@hagl.de wrote:
> timec...@gmail.com schrieb am Mittwoch, 5. Januar 2022 um 10:31:26 UTC+1:
> > > But you can also use Memoread() Function:
> > > ***********************************************************************
> > > FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen)
> > > LOCAL cText, nLines, i
> > > LOCAL aRest := {}
> > > DEFAULT nMaxLineLen TO 250
> > > IF File(cDatei)
> > > cText := MemoRead(cDatei)
> > > nLines := MlCount(cText,nMaxLineLen)
> > > ASize(aRest,nLines)
> > > FOR i := 1 TO nLines
> > > aRest[i] := Memoline(cText,nMaxLineLen,i)
> > > NEXT
> > > ENDIF
> > > RETURN aRest
> > thank you in...@hagl.de
> >
> > FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen) was just what i was looking for.
> > tested it, works ok. only 13 lines of code (less is more).
> >
> > but, how to determine the no. of lines in the/any .txt file.
> > (your e.g. DEFAULT nMaxLineLen TO 250 ) my users may have more/less no. of lines.
> > btw: i had never used Memoread,Mlcount,MemoLine till now.
> >
> > regards
> Hi,
> > but, how to determine the no. of lines in the/any .txt file.
> I dont undertand.
> MlCount(cText,nMaxLineLen,,,iif(nMaxLineLen>254,.t.,.f.)) returns the number of lines in the text file.
>
> nMaxLineLen is max length of a text line. You should set it higher than the length of the longest line. You can set it to 1000 or bigger, but when set higher than 254 you have to set the fifth param to .t.
>
> Do you not have a function description for xHb?
> ***************************************************************************************************
> MLCount( <cString> , ;
> [<nLineLen>] , ;
> [<nTabSize>] , ;
> [<lWrap>] , ;
> [<lLongLines>] ) --> nLineCount
>
> Arguments
> <cString>
> A character string or memo field to be counted. It can be a formatted text string that includes Tab and Hard/Soft carriage return characters.
> <nLineLen>
> A numeric value specifying the number of characters per line. It is usually a value between 4 and 254. If <nLineLen> is larger than 254 characters, parameter <lLongLines> must be set to .T. (true). The default value for <nLineLen> is 79.
> <nTabSize>
> A numeric value specifying the number of blank spaces the Tab character should be expanded to. It defaults to 4 blank spaces.
> <lWrap>
> A logical value indicating if word wrapping should be applied to <cString> when lines are counted. The default value is .T. (true), resulting in text lines being counted that contain whole words only. When a word does not fit entirely to the end of a text line, it is wrapped to the next text line. Passing .F. (false) for this parameter turns word wrapping off so that only lines ending with a hard carriage return are counted.
> <lLongLines>
> This parameter defaults to .F. (false). It must be
>
> Michael Hagl

thanks michael:
my bad. there it was in your example: nLines := MlCount(cText,nMaxLineLen)

this will now allow my users to set their own fonts/size/style... to their invoice print.
(post reading the .txt file & assigning the values to each array element)

i use pagescript32 for designing reports/outputs.
pssetfont(array[element1]as font, array[element17] as style, element2 as size...,xxx,yyy)
after getting the values, it would process then as e.g. pssetfont(arial,1,11,....)
the best part is, if the user has typed in any undecipherable font name, size,...in their .txt file,
pssetfont() will instead use as default a standard font or the previous proper assigned font...
(preventing crash or gibberish output)

appreciate your time & efforts.

Re: fopen(), freadstr()...

<dfb358dc-3cf4-4042-9257-e12ed9de7a31n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10445&group=comp.lang.xharbour#10445

  copy link   Newsgroups: comp.lang.xharbour
X-Received: by 2002:a05:620a:4495:: with SMTP id x21mr37115020qkp.633.1641381063656;
Wed, 05 Jan 2022 03:11:03 -0800 (PST)
X-Received: by 2002:ac8:5c8f:: with SMTP id r15mr47477274qta.632.1641381063504;
Wed, 05 Jan 2022 03:11:03 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.xharbour
Date: Wed, 5 Jan 2022 03:11:03 -0800 (PST)
In-Reply-To: <eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2401:4900:1c20:5427:c5a4:5ec1:143d:5a42;
posting-account=jZAeNwoAAABYWjMRM-FfqKkHfC3Iph0l
NNTP-Posting-Host: 2401:4900:1c20:5427:c5a4:5ec1:143d:5a42
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com> <cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com> <9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com> <14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
<eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dfb358dc-3cf4-4042-9257-e12ed9de7a31n@googlegroups.com>
Subject: Re: fopen(), freadstr()...
From: timecost...@gmail.com (timepro timesheet)
Injection-Date: Wed, 05 Jan 2022 11:11:03 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 93
 by: timepro timesheet - Wed, 5 Jan 2022 11:11 UTC

On Wednesday, January 5, 2022 at 3:49:40 PM UTC+5:30, in...@hagl.de wrote:
> timec...@gmail.com schrieb am Mittwoch, 5. Januar 2022 um 10:31:26 UTC+1:
> > > But you can also use Memoread() Function:
> > > ***********************************************************************
> > > FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen)
> > > LOCAL cText, nLines, i
> > > LOCAL aRest := {}
> > > DEFAULT nMaxLineLen TO 250
> > > IF File(cDatei)
> > > cText := MemoRead(cDatei)
> > > nLines := MlCount(cText,nMaxLineLen)
> > > ASize(aRest,nLines)
> > > FOR i := 1 TO nLines
> > > aRest[i] := Memoline(cText,nMaxLineLen,i)
> > > NEXT
> > > ENDIF
> > > RETURN aRest
> > thank you in...@hagl.de
> >
> > FUNCTION TxtFile2ArrayM(cDatei,nMaxLineLen) was just what i was looking for.
> > tested it, works ok. only 13 lines of code (less is more).
> >
> > but, how to determine the no. of lines in the/any .txt file.
> > (your e.g. DEFAULT nMaxLineLen TO 250 ) my users may have more/less no. of lines.
> > btw: i had never used Memoread,Mlcount,MemoLine till now.
> >
> > regards
> Hi,
> > but, how to determine the no. of lines in the/any .txt file.
> I dont undertand.
> MlCount(cText,nMaxLineLen,,,iif(nMaxLineLen>254,.t.,.f.)) returns the number of lines in the text file.
>
> nMaxLineLen is max length of a text line. You should set it higher than the length of the longest line. You can set it to 1000 or bigger, but when set higher than 254 you have to set the fifth param to .t.
>
> Do you not have a function description for xHb?
> ***************************************************************************************************
> MLCount( <cString> , ;
> [<nLineLen>] , ;
> [<nTabSize>] , ;
> [<lWrap>] , ;
> [<lLongLines>] ) --> nLineCount
>
> Arguments
> <cString>
> A character string or memo field to be counted. It can be a formatted text string that includes Tab and Hard/Soft carriage return characters.
> <nLineLen>
> A numeric value specifying the number of characters per line. It is usually a value between 4 and 254. If <nLineLen> is larger than 254 characters, parameter <lLongLines> must be set to .T. (true). The default value for <nLineLen> is 79.
> <nTabSize>
> A numeric value specifying the number of blank spaces the Tab character should be expanded to. It defaults to 4 blank spaces.
> <lWrap>
> A logical value indicating if word wrapping should be applied to <cString> when lines are counted. The default value is .T. (true), resulting in text lines being counted that contain whole words only. When a word does not fit entirely to the end of a text line, it is wrapped to the next text line. Passing .F. (false) for this parameter turns word wrapping off so that only lines ending with a hard carriage return are counted.
> <lLongLines>
> This parameter defaults to .F. (false). It must be
>
> Michael Hagl

thanks michael:
my bad. there it was in your example: nLines := MlCount(cText,nMaxLineLen)

this will now allow my users to set their own fonts/size/style... to their invoice print.
(post reading the .txt file & assigning the values to each array element)

i use pagescript32 for designing reports/outputs.
pssetfont(array[element1]as font, array[element17] as style, element2 as size...,xxx,yyy)
after getting the values, it would process then as e.g. pssetfont(arial,1,11,....)
the best part is, if the user has typed in any undecipherable font name, size,...in their .txt file,
pssetfont() will instead use as default a standard font or the previous proper assigned font...
(preventing crash or gibberish output)

appreciate your time & efforts.

Re: fopen(), freadstr()...

<srhami$9e5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10446&group=comp.lang.xharbour#10446

  copy link   Newsgroups: comp.lang.xharbour
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mc8647__...@mclink.it (FP)
Newsgroups: comp.lang.xharbour
Subject: Re: fopen(), freadstr()...
Date: Mon, 10 Jan 2022 14:01:00 +0100
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <srhami$9e5$1@dont-email.me>
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com>
<cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com>
<9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com>
<14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
<eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Jan 2022 13:01:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="59cf92f4055de125b935445225c42e87";
logging-data="9669"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rrm2jQ77ZBV179um8mmlY"
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101
Thunderbird/52.9.1
Cancel-Lock: sha1:jG4o4ikX7YU2hOK+vnF8RuxftOI=
In-Reply-To: <eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
Content-Language: it
 by: FP - Mon, 10 Jan 2022 13:01 UTC

Don't you have hb_aTokens() in xHarbour?

Re: fopen(), freadstr()...

<srkneg$ues$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10453&group=comp.lang.xharbour#10453

  copy link   Newsgroups: comp.lang.xharbour
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: webmas...@appliserver.com (Dan)
Newsgroups: comp.lang.xharbour
Subject: Re: fopen(), freadstr()...
Date: Tue, 11 Jan 2022 20:57:03 +0100
Organization: A noiseless patient Spider
Lines: 4
Message-ID: <srkneg$ues$1@dont-email.me>
References: <af2f2de4-fb97-4cd9-bb18-c5aae151f2a7n@googlegroups.com>
<4e3bf714-c69f-4f10-b906-4994e193fcbcn@googlegroups.com>
<cf3e86fb-c356-424d-a0bf-f21ce3253d69n@googlegroups.com>
<bd18597d-047c-4bda-a672-f51903200cccn@googlegroups.com>
<9f5899a2-c44d-432d-8453-4fc33856d3f5n@googlegroups.com>
<0073946a-5635-47e2-b0da-2bd7e1a9a1c3n@googlegroups.com>
<14bd34b7-7696-42d0-8369-6fde6f90a830n@googlegroups.com>
<eef880a7-4a3d-4be1-bd1e-a18c7227a830n@googlegroups.com>
<srhami$9e5$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 11 Jan 2022 19:57:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c16f9fb74154c60532522e729208039a";
logging-data="31196"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bhj4eHtlNS9dCDppBIsEA"
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Cancel-Lock: sha1:VEttUaWPDBPPYV+WK3crTzT3f7g=
In-Reply-To: <srhami$9e5$1@dont-email.me>
 by: Dan - Tue, 11 Jan 2022 19:57 UTC

Il 10/01/2022 14:01, FP ha scritto:
> Don't you have hb_aTokens() in xHarbour?
token() and related functions from ct.lib.
Dan

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor