B4J Question generating html or text file with linebreaks

Discussion in 'B4J Questions' started by hookshy, Jul 12, 2015.

  1. hookshy

    hookshy Well-Known Member Licensed User

    if I have a basic string like

    Code:
    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


    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Replace CRLF with "<br/>"
     
  3. hookshy

    hookshy Well-Known Member Licensed 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
     
  4. hookshy

    hookshy Well-Known Member Licensed 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:
     
  5. Roycefer

    Roycefer Well-Known Member Licensed User

    As a side note, you can call
    Code:
    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.
     
  6. picenainformatica

    picenainformatica Active Member Licensed User

    replace crlf with chr(13) & chr(10)
     
  7. hookshy

    hookshy Well-Known Member Licensed User

    It seems there is some key mising in GetSystemProperty ? any ideas
     
  8. Roycefer

    Roycefer Well-Known Member Licensed User

    Whoops, you have to provide a default response as the second argument in GetSystemProperty().
    Code:
    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.
     
  9. hookshy

    hookshy Well-Known Member Licensed User

    thanks
     
  10. hookshy

    hookshy Well-Known Member Licensed User

    This solved my problems , and now notepad see the line brake corectly
     
  11. hookshy

    hookshy Well-Known Member Licensed User

    I have tested also this method and does the work ...Thank you !
     
Loading...