View Single Post
  #31 (permalink)  
Old 07-31-2008, 12:35 PM
tsteward tsteward is offline
Senior Member
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 146
Send a message via MSN to tsteward
Default

I want to write a personal wiki. Using your library I can read a text file, interpret it and create the required htm.

My problem is I create links that are the name of other text files.
Is there a way I can load the text file for interpreting.

My Code so far (just test code)
Code:
Sub Globals
    'Declare the global variables here.
End Sub

Sub App_Start
  Form1.Show
  web.New1("Form1",10,30,770,500)
End Sub


Sub Button1_Click
    'web.Navigate(Textbox1.Text)
    web.url = Textbox1.Text 'either Navigate or assigning to Url will load the web page
End Sub

Sub GetFile(file)
 If FileExist (file) = true Then
  FileOpen (c1,file,cRead ,, cASCII)
   HtmStr = "<html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8>"
   HtmStr = HtmStr & "<title>homepage</title>"
   HtmStr = HtmStr & "<link rel=stylesheet href=file:///C:\Users\Tony\Documents\WM_Wiki_Pages\Locks\wikistyle.css Type=text/css>"
   HtmStr = HtmStr & "</head><body>"
            line = FileRead (c1)
   Do Until line = EOF
    If line <> EOF Then
                    If SubString(line, 0, 1) = "[" Then
                     If SubString(line,1,1) = "^" Then
                         ' do nothing
                            HtmStr = HtmStr & "Insert page here" & crlf
                        Else
                      HtmStr = HtmStr & "<p><a class=" & Chr(34) & "internal" & Chr(34) & " href=" & Chr(34)
                         HtmStr = HtmStr & SubString(line,1, StrLength(line)-2) & ".txt" & Chr(34) & ">" & SubString(line,1, StrLength(line)-2)
                         HtmStr = HtmStr & " </a> &nbsp;</p>" & crlf
                        End If
                    End If
                    If SubString(line, 0, 1) = "+" Then
                     HtmStr = HtmStr & "<h1><a name=Locks%20Wiki>"
                        HtmStr = HtmStr & SubString(line,1, StrLength(line))
                        HtmStr = HtmStr & "</a></h1>" & crlf
                    End If
                End If
                line = FileRead (c1)
   Loop
  FileClose (c1)
        web.DocumentText = HtmStr
 End If
End Sub

Sub Button2_Click
 GetFile("homepage.txt")
End Sub
Sub web_DocumentCompleted
    'Msgbox("Completed", web.Url)
End Sub

Sub web_Navigating
    GetFile(web.NavigatingURL)
End Sub

Sub web_Navigated
'    Msgbox("Navigated to" &  crlf & web.Url)
'    Textbox1.Text = web.Url
End Sub
Text file to read
Code:
[^header]
+Locks Wiki
[Access Control]
[Automotive]
[Key Cabinets-Boxes]
[Locks Via Brand]
[Motorcycles]
[Padlocks]
[Rolla Doors]
[Safes]
[Technical_Info]
[Test]

[^footer]
Reply With Quote