PBNSU, logiciel ou userlib&dll?

Programmation d'applications complexes
Avatar de l’utilisateur
cederavic
Messages : 1338
Inscription : lun. 09/févr./2004 23:38
Localisation : Bordeaux

PBNSU, logiciel ou userlib&dll?

Message par cederavic »

voila, normalement aujourd'hui je devait faire l'interface, et je me sui dit "tient, sa pourai etre simpas d'en faire une userlib" enfin si sa peut servir a quelqu'un.. vous etes interresser? (pour ceux qui ne connaisse pas, PBNS etait un logiciel pour convertir les source pb en fichier html avec couleur(maintenant plus que de simple couleur car j'utilise mes class CSS donc chacun peut ajouter des truc)
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

pour la lib, oui, c serai cool pour faire des progs qui traite tout un dossier d'un coup en automatique par exemple.
moi, je prends ;)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
cederavic
Messages : 1338
Inscription : lun. 09/févr./2004 23:38
Localisation : Bordeaux

Message par cederavic »

ben en fait sa permetrai a chacun de se faire son interface :)
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

perso , je préferais le source :)
Avatar de l’utilisateur
cederavic
Messages : 1338
Inscription : lun. 09/févr./2004 23:38
Localisation : Bordeaux

Message par cederavic »

elle y sera ;)
Avatar de l’utilisateur
cederavic
Messages : 1338
Inscription : lun. 09/févr./2004 23:38
Localisation : Bordeaux

Message par cederavic »

j'ai un pti probleme :roll:

quand je convertis une source avec mon truc, les commentaires ne sont pas mis en forme... et je ne vois vraiment pas pourquoi :(

voilas le code source (terminé en plus, j'ai juste ce probleme apres je peut en faire une userlib), la source est un peut long... mais je voi pas comment faire autrement :?

Code : Tout sélectionner

;[PureBasic Net Source Ultra - Programmer's Pack]
; Par : Marion Cédric
; Le : Mecredi 14 Avril 2004
; Pour : PureBasic 3.81 et 3.90

    #PBNSU_Comment         = 3
    #PBNSU_Constant        = 6
    #PBNSU_Function        = 9
    #PBNSU_Keyword         = 12
    #PBNSU_Operator        = 15
    #PBNSU_PBEditorComment = 18
    #PBNSU_String          = 21
    #PBNSU_Indentation     = 24
    #PBNSU_ConvertAll      = #PBNSU_Comment | #PBNSU_Constant | #PBNSU_Function | #PBNSU_Keyword | #PBNSU_Operator | #PBNSU_PBEditorComment | #PBNSU_String | #PBNSU_Indentation 

    #PBNSU_Error_FileIn         = 3
    #PBNSU_Error_FileOut        = 6
    #PBNSU_Error_FileKeyword    = 9
    #PBNSU_Error_FileConf       = 12
    #PBNSU_Error_FileCSS        = 15
    #PBNSU_Error_Class_Comment  = 18
    #PBNSU_Error_Class_Function = 21
    #PBNSU_Error_Class_Constant = 24
    #PBNSU_Error_Class_Keyword  = 27
    #PBNSU_Error_Class_Operator = 30
    #PBNSU_Error_Class_String   = 33
    #PBNSU_Error_Class_Variable = 36
    #PBNSU_Error_Init           = 39

    Global PBNSU_Initialized.b

    Global PBNSU_FileID_In.l
    Global PBNSU_FileID_Out.l
    Global PBNSU_FileTitle.s
    Global PBNSU_FileCSS.s

    Global PBNSU_LastError.l

    Global PBNSU_Class_Comment.s
    Global PBNSU_Class_Function.s
    Global PBNSU_Class_Constant.s
    Global PBNSU_Class_Keyword.s
    Global PBNSU_Class_Operator.s
    Global PBNSU_Class_String.s
    Global PBNSU_Class_Variable.s
    Global PBNSU_BGColor.s

    NewList FunctionList.s()  
    NewList ConstantList.s() 
    NewList StringList.s()
    NewList OldStringList.s()
    NewList KeywordsList.s()

Procedure.s PBNSU_Convert_PBEditorComment(Line.s)  
  If FindString(Line, "; ExecutableFormat=", 0) 
    ProcedureReturn ""
  ElseIf FindString(Line, "; CursorPosition=", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; FirstLine=", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; Executable=", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; EnableAsm", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; EnableNT4", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; EnableXP", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; EnableOnError", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; UseIcon=", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; CommandLine=", 0)    
    ProcedureReturn ""    
  ElseIf FindString(Line, "; DisableDebugger", 0)
    ProcedureReturn ""
  ElseIf FindString(Line, "; EOF", 0)    
    ProcedureReturn ""    
  Else    
    ProcedureReturn Line    
  EndIf  
EndProcedure

Procedure PBNSU_CountFileLines()  
  Protected CountLine   
    
  UseFile(PBNSU_FileID_In)  
  Repeat    
    ReadString()    
    CountLine + 1    
  Until Eof(1)  
  FileSeek(0)  
    
  ProcedureReturn CountLine
EndProcedure

Procedure.s PBNSU_ClearLine(Line.s)    
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_Comment + "'>", "", 1)  
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_Function + "'>", "", 1)  
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_Constant + "'>", "", 1)  
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_Keyword + "'>", "", 1) 
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_Operator + "'>", "", 1) 
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_String + "'>", "", 1)  
  Line = ReplaceString(Line, "<spanclass='" + PBNSU_Class_Variable+ "'>", "", 1) 
  Line = ReplaceString(Line, "</span>", "", 1)  
  Line = ReplaceString(Line, "</span>", "", 1)  
  Line = ReplaceString(Line, "</span>", "", 1)  
  Line = ReplaceString(Line, "</span>", "", 1) 
  Line = ReplaceString(Line, "</span>", "", 1) 
  Line = ReplaceString(Line, "</span>", "", 1)  
  Line = ReplaceString(Line, "</span>", "", 1)  
   
  ProcedureReturn Line  
EndProcedure

Procedure PBNSU_MakeHeader()  
  UseFile(PBNSU_FileID_Out)  
    
  WriteStringN("<html>")  
  WriteStringN("<head>")  
  WriteStringN("<title>" + PBNSU_FileTitle + "</title>")  
  WriteStringN("  <meta name=generator content=PB Net Source Ultra>")
  WriteStringN("  <link rel=" + Chr(34) + "stylesheet" + Chr(34) + " type=" + Chr(34) + "text/css" + Chr(34) + " href=" + PBNSU_FileCSS + ">")
  WriteStringN("</head>")  
  WriteStringN("<body bgcolor=#" + PBNSU_BGColor + "><span class='v'>")    
EndProcedure

Procedure PBNSU_MakeEndHeader()  
  UseFile(PBNSU_FileID_Out)    
 
  WriteStringN("</span></body>")  
  WriteStringN("</html>")  
EndProcedure

Procedure.s PBNSU_Convert_Keyword(Line.s)  
  Protected sKeyword.s  
  
  Line = Line + " "  
  ForEach KeywordsList()
    sKeyword= KeywordsList()    
    If sKeyword<> " " 
    
      If FindString(Line, ";" + sKeyword+ " ", 1)        
      ElseIf FindString(Line, " " + sKeyword+ ".", 1)       
        Line = ReplaceString(Line, sKeyword+ ".", "<spanclass='" + PBNSU_Class_Keyword + "'>" + sKeyword+ "</span>.", 1)      
      ElseIf FindString(Line, sKeyword+ " ", 1)        
        Line = ReplaceString(Line, sKeyword+ " ", "<spanclass='" + PBNSU_Class_Keyword + "'>" + sKeyword+ "</span> ", 1)    
      ElseIf FindString(Line, " " + sKeyword, 1)        
        Line = ReplaceString(Line, " " + sKeyword, "<spanclass='" + PBNSU_Class_Keyword + "'> " + sKeyword+ "</span>", 1)    
      EndIf     
       
    EndIf    
  Next
  
  ProcedureReturn line     
EndProcedure

Procedure.s PBNSU_Convert_Function(Line.s)  
  Protected ParamPos.l  
  Protected EndFunction.l  
  Protected StartFunction.l  
  Protected ChrFunction.s  
  Protected Function.s  
  Protected AddFunction.b  
    
  Repeat   
    ParamPos = FindString(Line, "(", ParamPos + 1)    
        
    If ParamPos      
            
      EndFunction = ParamPos      
      StartFunction = ParamPos      
            
      Repeat
        StartFunction - 1        
        ChrFunction = Mid(Line, StartFunction, 1)        
        If ChrFunction = ">"          
          ChrFunction = ""          
          StartFunction + 1          
        EndIf        
      Until ChrFunction = " " Or ChrFunction = "" Or ChrFunction = "," Or StartFunction = -1 
            
      If StartFunction = -1        
        StartFunction = 0        
      EndIf      
            
      Function = Mid(Line, StartFunction, EndFunction - StartFunction)      
      AddFunction = #True      
      ResetList(FunctionList())      
            
      ForEach FunctionList()
        If FunctionList() = Function          
          AddFunction = #False          
        Else          
                    
        EndIf        

      Next      
            
      If AddFunction = #True        
        If Function <> "" And Function <> " "          
          AddElement(FunctionList())          
          FunctionList() = Function          
        EndIf        
      EndIf
            
    EndIf
  Until ParamPos = 0
    
  ResetList(FunctionList())  
    
  ForEach FunctionList()
    Line = ReplaceString(Line, FunctionList(), "<spanclass='" + PBNSU_Class_Function + "'>" + FunctionList() + "</span>", 1)    
  Next
    
  ProcedureReturn Line  
    
EndProcedure

Procedure.s PBNSU_Convert_Constant(Line.s)  
  Protected ConstantPos.l  
  Protected EndConstant.l  
  Protected StartConstant.l  
  Protected ChrConstant.s  
  Protected Constant.s  
  Protected AddConstant.b  
    
  Repeat  
        
    ConstantPos = FindString(Line, "#", ConstantPos + 1)    
        
    If ConstantPos      
            
      EndConstant = ConstantPos      
      StartConstant = ConstantPos      
            
      Repeat      
        EndConstant + 1        
        ChrConstant = Mid(Line, EndConstant, 1)        
      Until ChrConstant = " " Or ChrConstant = "" Or ChrConstant = "," Or ChrConstant = "|" Or ChrConstant = ")" Or ChrConstant = " = "      
            
      Constant = Mid(Line, StartConstant, EndConstant - StartConstant)      
      AddConstant = #True      
      ResetList(ConstantList())      
            
      ForEach ConstantList()     
        If ConstantList() = Constant          
          AddConstant = #False          
        Else          
                    
        EndIf        
      Next      
            
      If AddConstant = #True        
        AddElement(ConstantList())        
        ConstantList() = Constant        
      EndIf      
            
    EndIf    
        
  Until ConstantPos = 0
    
  ResetList(ConstantList())  
    
  ForEach ConstantList()   
    Line = ReplaceString(Line, ConstantList(), "<spanclass='" + PBNSU_Class_Constant + "'>" + ConstantList() + "</span>", 1)    
  Next  
    
  ProcedureReturn Line  
    
EndProcedure

Procedure.s PBNSU_Convert_String(Line.s)  
  Protected StringPos.l  
  Protected EndString.l  
  Protected StartString.l  
  Protected ChrString.s  
  Protected String.s  
  Protected OldString.s  
  Protected AddString.b  
    
  
    
  Repeat   
        
    StringPos = FindString(Line, Chr(34), EndString + 1)    
        
    If StringPos      
            
      EndString = StringPos      
      StartString = StringPos  +1    
            
      Repeat       
        EndString + 1        
        ChrString = Mid(Line, EndString, 1)  
      Until ChrString = Chr(34) 
            
      String = Mid(Line, StartString - 1, EndString - StartString + 2)      
      OldString = String      
      String = PBNSU_ClearLine(String)      
      AddString = #True      
            
      ResetList(StringList())   
      ResetList(OldStringList())   
            
      ForEach StringList() : NextElement(OldStringList())
        If StringList() = String          
          AddString = #False          
        Else          
                    
        EndIf        
      Next      
            
      If AddString = #True        
        AddElement(StringList())  
        AddElement(OldStringList())     
        StringList() = String      
        OldStringList() = OldString
      EndIf      
            
    EndIf    
    
  Until StringPos = 0
    
  ResetList(StringList())  
  ResetList(OldStringList())
    
  ForEach StringList() : NextElement(OldStringList())
    Line = ReplaceString(Line, OldStringList(), "<spanclass='" + PBNSU_Class_String + "'>" + StringList() + "</span>", 1)    
  Next  
    
  ProcedureReturn Line  
    
EndProcedure

Procedure.s PBNSU_Convert_Comment(Line.s) 
  Protected CommentPos.l  
  Protected Comment.s  
  Protected OldComment.s  
    
  CommentPos = FindString(Line, ";", 1)  
    
  If CommentPos    
    Comment = Mid(Line, CommentPos, Len(Line) - CommentPos)    
    OldComment = Comment    
    Comment = PBNSU_ClearLine(Comment)    
    Line = ReplaceString(Line, OldComment, "<spanclass='" + PBNSU_Class_Comment + "'>" + Comment + "</span> ", 1)    
  EndIf  
    
  ProcedureReturn Line  
    
EndProcedure

Procedure.s PBNSU_Convert_Operator(Line.s)  
  Line = ReplaceString(Line, " = ",  "<spanclass='" + PBNSU_Class_Operator + "'> =</span> ", 1)  
  Line = ReplaceString(Line, " < ",  "<spanclass='" + PBNSU_Class_Operator + "'> <</span> ", 1)  
  Line = ReplaceString(Line, " > ",  "<spanclass='" + PBNSU_Class_Operator + "'> ></span> ", 1)  
  Line = ReplaceString(Line, " + ",  "<spanclass='" + PBNSU_Class_Operator + "'> +</span> ", 1)  
  Line = ReplaceString(Line, " - ",  "<spanclass='" + PBNSU_Class_Operator + "'> -</span> ", 1)  
  Line = ReplaceString(Line, " / ",  "<spanclass='" + PBNSU_Class_Operator + "'> /</span> ", 1)  
  Line = ReplaceString(Line, " * ",  "<spanclass='" + PBNSU_Class_Operator + "'> *</span> ", 1)  
  Line = ReplaceString(Line, " & ",  "<spanclass='" + PBNSU_Class_Operator + "'> &</span> ", 1)  
  Line = ReplaceString(Line, " | ",  "<spanclass='" + PBNSU_Class_Operator + "'> |</span> ", 1)  
  Line = ReplaceString(Line, " << ", "<spanclass='" + PBNSU_Class_Operator + "'> <<</span> ", 1)  
  Line = ReplaceString(Line, " >> ", "<spanclass='" + PBNSU_Class_Operator + "'> >></span> ", 1)  
  Line = ReplaceString(Line, " : ",  "<spanclass='" + PBNSU_Class_Operator + "'> :</span> ", 1)  
  Line = ReplaceString(Line, ",",    "<spanclass='" + PBNSU_Class_Operator + "'>,</span>", 1)  
    
  ProcedureReturn Line  
EndProcedure

Procedure.s PBNSU_SetFunction(Line.s)  
  Line = ReplaceString(Line, ")", "<spanclass='" + PBNSU_Class_Function + "'>)</span>", 1)  
  Line = ReplaceString(Line, "(", "<spanclass='" + PBNSU_Class_Function + "'>(</span>", 1)  
    
  ProcedureReturn Line  
EndProcedure

Procedure.s PBNSU_SetIndentation(Line.s)  
  ProcedureReturn ReplaceString(Line, " ", "&nbsp;")  
EndProcedure

Procedure.s PBNSU_SetCorrectHTML(Line.s)  
  ProcedureReturn ReplaceString(Line, "<spanclass='", "<span class='")  
EndProcedure

Procedure PBNSU_GetLastError()
  ProcedureReturn PBNSU_LastError
EndProcedure

Procedure PBNSU_SetError(Flag.l)
  PBNSU_LastError = Flag
EndProcedure

Procedure PBNSU_Init(FileKeyID.l, FileKeyName.s, FileConfName.s, FileCSSName.s)
  If PBNSU_Initialized = #True
    PBNSU_SetError(#PBNSU_Error_Init)
    ProcedureReturn #False
  Else
    
  
    If ReadFile(FileKeyID, FileKeyName) = 0
      PBNSU_SetError(#PBNSU_Error_FileKeyword)
      ProcedureReturn #False
    Else
      Repeat
        AddElement(KeywordsList())
        KeywordsList() = Trim(ReadString())
      Until Eof(FileKeyID)
      CloseFile(FileKeyID)
    EndIf
    
    If ReadFile(FileKeyID, FileCSSName) = 0
      PBNSU_SetError(#PBNSU_Error_FileCSS)
      ProcedureReturn #False
    Else
      PBNSU_FileCSS = FileCSSName
      CloseFile(FileKeyID)
    EndIf
    
    If OpenPreferences(FileConfName)
      PreferenceGroup("Class")
        PBNSU_Class_Comment = ReadPreferenceString("comment", "")
        PBNSU_Class_Function = ReadPreferenceString("function", "")
        PBNSU_Class_Constant = ReadPreferenceString("constant", "")
        PBNSU_Class_Keyword = ReadPreferenceString("keyword", "")
        PBNSU_Class_Operator = ReadPreferenceString("operator", "")
        PBNSU_Class_String = ReadPreferenceString("string", "")
        PBNSU_Class_Variable = ReadPreferenceString("variable", "")
      PreferenceGroup("Global")
        PBNSU_BGColor = ReadPreferenceString("BGColor", "FFFFE6")
      ClosePreferences()
      
      If PBNSU_Class_Comment = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Comment)
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Function = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Function )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Constant = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Constant )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Keyword = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Keyword )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Operator = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Operator )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_String = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_String )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Variable = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Variable )
        ProcedureReturn #False
      EndIf
  
    Else
      PBNSU_SetError(#PBNSU_Error_FileConf)
      ProcedureReturn #False
    EndIf
  EndIf
  
  PBNSU_Initialized = #True
  ProcedureReturn #True
EndProcedure

Procedure PBNSU_StartConvert(FileIDIn.l, FileNameIn.s, FileIDOut.l, FileNameOut.s, Title.s, Flags.l)  
  Protected LastLine.s  
  Protected CurrentLine.s  
  Protected NextLine.s  
  Protected Timert
  
  PBNSU_FileTitle = Title
  
  PBNSU_FileID_In = FileIDIn
  PBNSU_FileID_Out = FileIDOut
  
  If PBNSU_FileTitle = ""
    PBNSU_FileTitle = GetFilePart(FileNameIn)
  EndIf
  
  If ReadFile(PBNSU_FileID_In, FileNameIn) = 0
    PBNSU_SetError(#PBNSU_Error_FileIn)
    ProcedureReturn #False
  EndIf
  If CreateFile(PBNSU_FileID_Out, FileNameOut) = 0
    CloseFile(PBNSU_FileID_In)
    PBNSU_SetError(#PBNSU_Error_FileOut)
    ProcedureReturn #False
  EndIf 
  
  Timert = GetTickCount_()
  
  PBNSU_MakeHeader()  
    
  LastLine = CurrentLine  
  CurrentLine = ReadString()  
  NextLine = ReadString()  
    
  While Eof(PBNSU_FileID_In) = 0            
        
    UseFile(PBNSU_FileID_In)    
        
    LastLine = CurrentLine    
    CurrentLine = NextLine
    NextLine = ReadString()        
    
    If Flags & #PBNSU_PBEditorComment = #PBNSU_PBEditorComment
      CurrentLine = PBNSU_Convert_PBEditorComment(CurrentLine)  
    EndIf
    If Flags & #PBNSU_Operator = #PBNSU_Operator
      CurrentLine = PBNSU_Convert_Operator(CurrentLine)      
    EndIf
    If Flags & #PBNSU_Keyword = #PBNSU_Keyword
      CurrentLine = PBNSU_Convert_Keyword(CurrentLine)     
    EndIf
      If Flags & #PBNSU_Function = #PBNSU_Function
    CurrentLine = PBNSU_Convert_Function(CurrentLine)    
    EndIf
    If Flags & #PBNSU_Constant = #PBNSU_Constant
      CurrentLine = PBNSU_Convert_Constant(CurrentLine)    
    EndIf
    If Flags & #PBNSU_String = #PBNSU_String
      CurrentLine = PBNSU_Convert_String(CurrentLine)  
    EndIf
    If Flags & #PBNSU_Comment = #PBNSU_Comment
      CurrentLine = PBNSU_Convert_Comment(CurrentLine)    
    EndIf  
    
    If Flags & #PBNSU_Function = #PBNSU_Function
      CurrentLine = PBNSU_SetFunction(CurrentLine)    
    EndIf
    If Flags & #PBNSU_Indentation = #PBNSU_Indentation 
      CurrentLine = PBNSU_SetIndentation(CurrentLine)    
    EndIf
    CurrentLine = PBNSU_SetCorrectHTML(CurrentLine)    
        
    If CurrentLine <> ""      
      If Trim(LastLine) = ""        
        CurrentLine = "<p>" + CurrentLine        
      EndIf      
            
      If Trim(NextLine) = ""        
        CurrentLine = CurrentLine + "</p>"        
      Else        
        CurrentLine = CurrentLine + "<br>"        
      EndIf      
            
      CurrentLine = Trim(CurrentLine)      
            
      UseFile(PBNSU_FileID_Out)      
      WriteStringN(CurrentLine)      
    EndIf    
        
  Wend  
    
  PBNSU_MakeEndHeader()  
  
  PBNSU_FileTitle = ""
    
  CloseFile(PBNSU_FileID_In)  
  CloseFile(PBNSU_FileID_Out)  
  
  ForEach ConstantList()
    DeleteElement(ConstantList())
  Next
  ForEach FunctionList()
    DeleteElement(FunctionList())
  Next
  ForEach StringList()
    DeleteElement(StringList())
  Next
  ForEach OldStringList()
    DeleteElement(OldStringList())
  Next
    
  res = GetTickCount_() - Timert
  If res < 1 : res = 1 : EndIf
  ProcedureReturn res
    
EndProcedure

Procedure.s PBNSU_TranslateError(Flag.l)

  Select Flag
    Case #PBNSU_Error_FileIn
      ProcedureReturn "Le fichier source n'a pas pu être ouvert."
    Case #PBNSU_Error_FileOut
      ProcedureReturn "Le fichier html n'a pas pu être créé."
    Case #PBNSU_Error_FileKeyword
      ProcedureReturn "Le fichier keywords n'a pas pu être ouvert."
    Case #PBNSU_Error_FileConf
      ProcedureReturn "Le fichier conf n'a pas pu être ouvert."
    Case #PBNSU_Error_FileCSS
      ProcedureReturn "Le fichier CSS n'existe pas."
    Case #PBNSU_Error_Class_Comment
      ProcedureReturn "Le nom de la class Comment est incorrect."
    Case #PBNSU_Error_Class_Function
      ProcedureReturn "Le nom de la class Function est incorrect."
    Case #PBNSU_Error_Class_Constant 
      ProcedureReturn "Le nom de la class Constant est incorrect."
    Case #PBNSU_Error_Class_Keyword 
      ProcedureReturn "Le nom de la class Keyword est incorrect."
    Case #PBNSU_Error_Class_Operator 
      ProcedureReturn "Le nom de la class Operator est incorrect."
    Case #PBNSU_Error_Class_String 
      ProcedureReturn "Le nom de la class String est incorrect."
    Case #PBNSU_Error_Class_Variable 
      ProcedureReturn "Le nom de la class Variable est incorrect."
    Case #PBNSU_Error_Init
      ProcedureReturn "PBNSU est dejas initialisé."
  EndSelect

EndProcedure

Procedure PBNSU_UpdateKeywordsList(FileKeyID.l, FileKeyName.s)
  If ReadFile(FileKeyID, FileKeyName) = 0
    PBNSU_SetError(#PBNSU_Error_FileKeyword)
    ProcedureReturn #False
  Else
    Repeat
      AddElement(KeywordsList())
      KeywordsList() = Trim(ReadString())
    Until Eof(FileKeyID)
    CloseFile(FileKeyID)
  EndIf
  
  ProcedureReturn #True
EndProcedure

Procedure PBNSU_ChangeConfFile(FileConfName.s)
  If OpenPreferences(FileConfName)
    PreferenceGroup("Class")
      PBNSU_Class_Comment = ReadPreferenceString("comment", "")
      PBNSU_Class_Function = ReadPreferenceString("function", "")
      PBNSU_Class_Constant = ReadPreferenceString("constant", "")
      PBNSU_Class_Keyword = ReadPreferenceString("keyword", "")
      PBNSU_Class_Operator = ReadPreferenceString("operator", "")
      PBNSU_Class_String = ReadPreferenceString("string", "")
      PBNSU_Class_Variable = ReadPreferenceString("variable", "")
      
      If PBNSU_Class_Comment = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Comment)
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Function = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Function )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Constant = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Constant )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Keyword = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Keyword )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Operator = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Operator )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_String = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_String )
        ProcedureReturn #False
      EndIf
      If PBNSU_Class_Variable = ""
        ClosePreferences()
        PBNSU_SetError(#PBNSU_Error_Class_Variable )
        ProcedureReturn #False
      EndIf
        
    PreferenceGroup("Global")
      PBNSU_BGColor = ReadPreferenceString("BGColor", "FFFFE6")
    ClosePreferences()
  Else
    PBNSU_SetError(#PBNSU_Error_FileConf)
    ProcedureReturn #False
  EndIf
  
  ProcedureReturn #True
EndProcedure

Procedure PBNSU_ChangeCSSFile(FileCssID.l, FileCSSName.s)
  If ReadFile(FileCssID, FileCSSName) = 0
    PBNSU_SetError(#PBNSU_Error_FileCSS)
    ProcedureReturn #False
  Else
    PBNSU_FileCSS = FileCSSName
    CloseFile(FileCssID)
  EndIf
  
  ProcedureReturn #True
EndProcedure
le bout de code de test :

Code : Tout sélectionner

If PBNSU_Init(0, "keywords.sys", "config.inf", "class.css") = 0
  Debug PBNSU_TranslateError(PBNSU_GetLastError())
EndIf

Time = PBNSU_StartConvert(1, "example.pb", 2, "example.html", "", #PBNSU_ConvertAll)
If Time = 0
  Debug PBNSU_TranslateError(PBNSU_GetLastError())
EndIf
le fichier config.inf contient ça :

Code : Tout sélectionner

[Global]
BGColor = FFFFE6
[Class]
comment = m
function = f
constant = c
keyword = k
operator = o
string = s
variable = v
le fichier class.css :

Code : Tout sélectionner

  <style type="text/css">
    .m { color:#996666; font-size:10pt; font-style:italic; font-family:Courier; font-weight:normal; }
    .c { color:#996699; font-size:10pt; font-style:normal; font-family:Courier; font-weight:bold; }
    .f { color:#000066; font-size:10pt; font-style:normal; font-family:Courier; font-weight:normal; }
    .k { color:#000066; font-size:10pt; font-style:normal; font-family:Courier; font-weight:bold; }
    .o { color:#9999FF; font-size:10pt; font-style:normal; font-family:Courier; font-weight:normal; }
    .s { color:#006633; font-size:10pt; font-style:normal; font-family:Courier; font-weight:normal; }
    .v { color:#666666; font-size:10pt; font-style:normal; font-family:Courier; font-weight:normal; }
  </style>
et le fichier keywords.sys on s'en fou, on en a pas besoin, fait en un vide.
pour PBNSU_StartConvert(id du fichier source, chemin du fichier source, id du fichier html, chemin du fichier html, titre de la page, options) id du fichier, vous le choisissez et sa l'ouvre, ouvrer pas un fichier avec cet id avant! bon je croit que c'est tout, si quelqu'un trouve ou est le bleme.. parceque moi la je patauge completement ...

Merci d'avance:)
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

Merci pour le code ,j'y jetterai un oeil plus tard :)
Répondre