Results 1 to 9 of 9

Thread: Still cant get CGI scripts to save correctly..HELP??

  1. #1
    Guest
    I posted an article earlier on saving a cgi script using richtextbox it loses all of its formatting because CGI doesnt use the vbcrlf formatting instead it uses only a linefeed if Im correct..Displayed as a /n in cgi. If im wrong correct me on this..But anyways I want to be able to save a cgi script using richtextbox in its native format without losing any formatting and open it again so it keeps its format. Right now when I save I lose all linefeeds and all the text is on one line..Can someone please help me with this?

    It seems when it opens back up the text doesnt even contain vblf or vbcr at all..So I cant really get it back to its original format and the the script is corrupt..

  2. #2
    Guest
    What actions do you perform on the text before saving it?
    And what kind of actions after loading it?

  3. #3
    Guest
    I dont apply any..Once you get the text in ANSI format such as how Textpad can save in ANSI format you dont need to do anything to load the cgi script in normal format..Also the first time I load the script it looks fine but its when I save it that it loses all of its proper formatting..I need to figure out what the program Textpad or notepad in windows 2000 mean when they say Encode: ANSI below filetypes in the save dialog....That seems to fix the problem straight off

  4. #4
    Guest
    How do you save the file?
    I mean, if you can, post the code that saves the file.

  5. #5
    Guest
    Code:
    Public Sub ShowSave()
    Dim CmdDlg As New cCommonDialog
    Set CmdDlg = New cCommonDialog
    CmdDlg.Filter = cFilters
    
    If ActiveForm.txtMain.FileName = "" Then
    
        If Left(ActiveForm.Caption, 1) = "*" Then
        CmdDlg.FileName = Right(ActiveForm.Caption, Len(ActiveForm.Caption) - 1)
        Else
        CmdDlg.FileName = ActiveForm.Caption
        End If
    Else
    CmdDlg.FileName = ActiveForm.txtMain.FileName
    End If
    
    CmdDlg.DialogTitle = "Save Script"
    CmdDlg.ShowSave
    If CmdDlg.FileName = "" Then Exit Sub
    ActiveForm.txtMain.SaveFile CmdDlg.FileName, rtfText
    ActiveForm.txtMain.LoadFile CmdDlg.FileName, rtfText
    ActiveForm.Caption = FileGetName(CmdDlg.FileName)
    AddRecentList CmdDlg.FileName
    ActiveForm.txtChanged = tsfalse
    Set CmdDlg = Nothing
    End Sub

  6. #6
    Guest
    Try using Open...Close instead of using the SaveFile method:
    Code:
    Dim hFile As Long
    hFile = FreeFile
    
    Open CmdDlg.FileName For Output As hFile
        Print #hFile, ActiveForm.txtMain.Text
    Close
    This way you know the file is saved EXACTLY as it appears in the rtf box.

    Similarly you can use the same method to read the file.

    Try it and let me know.

  7. #7
    Guest
    I gotta go to sleep, it's almost 6:00am here.
    I'll check this thread tomorrow.

    Good night.

  8. #8
    Guest
    Yeah I was gonna try that eventually hehe...It seemed to have worked .. I will do some further testing to see if this works for all cgi scripts =]

  9. #9
    Guest
    Glad I could help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width