B4J Question generating html or text file with linebreaks

hookshy

Well-Known Member
Licensed User
Longtime User
if I have a basic string like

B4X:
dim sb as stringbuilder
sb.initialise
sb.append("item1").append(crlf)
sb.append("item2").append(crlf)
sb.append("item3").append(crlf)
IN NOTEPAD THIS LOOKS LIKE THIS: item1item2item3
If I edit the document with notepad and press enter after each item it looks like
item1
item2
item3

My webserver seems to like the second format and I could not make it like this !
the document as described in the code below will be acctually a html file but I have same problem as described below I edit html document with notepad press enter after each line and then everthing is ok

Any ideas how this page break will be generated corectly ?
I have tried using <p> and </p> or <li></li> but something is not doing write and I do not understand what ?
Thank you


B4X:
sub generate_members
If lastpath.Length>0 Then 
Dim sb1 As StringBuilder
sb1.Initialize


sb1.Append("<!DOCTYPE html>").Append(CRLF)
sb1.Append("<html>")

For k=0 To station.Tabs.Size-1
    For i=1 To pnl_tixi(k).NumberOfNodes-1 'omite back image

        Dim sb As StringBuilder
        sb.Initialize

            Dim n As Node
            n=pnl_tixi(k).GetNode(i)
            Dim tagx As String
            tagx=n.tag


           
        Dim newdes As imgdes
        newdes=propmap(station.SelectedIndex).Get(n.Tag)

            sb.Append("<li>")
            sb.Append(n.tag).Append(",")'0
            sb.Append("&#xae;/Process/Bus1/Device_0/").Append(newdes.var1).Append(";")
            sb.Append("</li>").Append(CRLF)
   
            sb1.Append(sb.ToString)
    Next 
Next

sb1.Append("</html>")
Log(sb1.ToString)

    File.WriteString(lastpath,"tixi.html",sb1.ToString)
   
   
Notificare(file_path(lastpath),"file ready")

Else 
bd.ShowInformation("Create new project first !","Generate members","jFX-HMI BUILDER")
End If 

  end sub
 

hookshy

Well-Known Member
Licensed User
Longtime User
I guess html tags are working fine ..<br>, <p> or <li> I have problems with notepad to generate list or page break ..thinking of it write now
It is strange ...I am writeing html file using html tags with file.writestring ..I guess this is correct
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
my webserver recognise the document just when I edit it with notepad and press enter to make new feed ...anywasy the page is displaying with line breakes ...but the server itself works when I manually edit the document and press enter to make newline after each variable :rolleyes:
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
As a side note, you can call
B4X:
Dim ls as String = GetSystemProperty("line.separator")
sb.append("stuff").append(ls)
to get and use the operating system's line separator character. The Windows line separator is different from the Unix/Linux line separator, even though most Windows programs will recognize the latter. Notepad is the exception, it only seems to recognize the Windows line separator.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Whoops, you have to provide a default response as the second argument in GetSystemProperty().
B4X:
Dim ls as String = GetSystemProperty("line.separator", "DEFAULT")
When typing that into the B4J IDE, if you press the comma inside the parentheses, you should see a list of the parameters you have to pass to the function.
 
Upvote 0
Top