• fopen(), freadstr()...

    From timepro timesheet@21:1/5 to All on Mon Jan 3 02:42:30 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From poopall@21:1/5 to timec...@gmail.com on Tue Jan 4 05:20:32 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From timepro timesheet@21:1/5 to poopall on Tue Jan 4 07:04:42 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Hagl@21:1/5 to timec...@gmail.com on Tue Jan 4 08:01:20 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From timepro timesheet@21:1/5 to in...@hagl.de on Tue Jan 4 21:22:28 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Hagl@21:1/5 to timec...@gmail.com on Tue Jan 4 23:58:42 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From timepro timesheet@21:1/5 to All on Wed Jan 5 01:31:25 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From timepro timesheet@21:1/5 to in...@hagl.de on Wed Jan 5 03:11:03 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From PARESH VALIA@21:1/5 to in...@hagl.de on Wed Jan 5 03:07:52 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Hagl@21:1/5 to timec...@gmail.com on Wed Jan 5 02:19:39 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From FP@21:1/5 to All on Mon Jan 10 14:01:00 2022
    Don't you have hb_aTokens() in xHarbour?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan@21:1/5 to All on Tue Jan 11 20:57:03 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)