J'ai essayé de convertir un code du grand ERIX14.
ça c'est bien pasé, jusqu'à la fin ou j'arrive pas a avoir la composante bleue

Elle est remplacé par le vert.
J'ai encore merdoyé quelque par

Si "quinquin" y sait ou

Code : Tout sélectionner
; Code original (Convertir un fichier TXT en HTML) LoadTxtSaveHtml de Erix14
; Transformé en convertion de variable + Choix couleur texte et fond et taille + Indentation par KCC
Procedure.s ConvertTxtEnHtml(Texte.s, TailleCaracteres = 4, CouleurFond = 0, CouleurCaracteres = 0) ;CouleurFond = -1 (Gris systeme)
If Len(Texte) =< 0
ProcedureReturn "Erreur(Texte à convertir inexistant)"
EndIf
Define TexteHTML.s
Structure MonChar
Char.b
EndStructure
#Txt = 0
#Html = 1
#Memoire = 0
#Vrai = 1
#Faux = 0
If Not CouleurCaracteres
EcritureCouleur.s = "color=#0000000"
Else
EcritureCouleur.s = "color=" + Chr(34) + Hex(Red(CouleurCaracteres)) + Hex(Green(CouleurCaracteres)) + Hex(Blue(CouleurCaracteres)) + Chr(34)
EndIf
If CouleurFond = -1
Color = GetSysColor_(#COLOR_3DFACE)
WebFondCouleur.s = Chr(34) + Hex(Red(Color)) + Hex(Green(Color)) + Hex(Blue(Color)) + Chr(34)
Else
WebFondCouleur.s = Chr(34) + Hex(Red(CouleurFond)) + Hex(Green(CouleurFond)) + Hex(Blue(CouleurFond)) + Chr(34)
EndIf
LongueurTxt = Len(Texte)
MemoryID = AllocateMemory(LongueurTxt)
PokeS(MemoryID, Texte, LongueurTxt)
TexteHTML + "<html>"
TexteHTML + "<head>"
TexteHTML + "<title>" + "test" + "</title>"
TexteHTML + "<meta http-equiv=" + "Content-Type" + "content=" + "text/html; charset=iso-8859-1" + ">"
TexteHTML + "</head>"
TexteHTML + "<body bgcolor=" + WebFondCouleur + " leftmargin=" + Chr(34) + "10" + Chr(34)
TexteHTML + " topmargin=" + Chr(34) + "10" + Chr(34) + " marginwidth=" + Chr(34) + "10" + Chr(34) + " marginheight=" + Chr(34) + "10" + Chr(34) + ">"
TexteHTML + "<table width=" + Chr(34) + "100%" + Chr(34) + " border=" + Chr(34) + "0" + Chr(34) + " cellpadding=" + Chr(34) + "0" + Chr(34) + " cellspacing=" + Chr(34) + "0" + Chr(34) + ">"
TexteHTML + "<!--DWLayoutTable-->"
TexteHTML + "<tr>"
TexteHTML + "<td width=" + Chr(34) + "100%" + Chr(34) + " height=" + Chr(34) + "100" + Chr(34) + " valign=" + Chr(34) + "top" + Chr(34) + "><div align=" + Chr(34) + "justify" + Chr(34) + "><font size=" + Chr(34) + Str(TailleCaracteres) + Chr(34) + " face=" + Chr(34) + "Verdana, Arial, Helvetica" + Chr(34) + " " + EcritureCouleur + ">"
*PointeurTxt.MonChar = MemoryID
Espace_HTML$ = ""
Ligne_de_txt$ = ""
Debut.b = #Vrai
For t.l = 1 To LongueurTxt
If *PointeurTxt\Char > 0
c.l = *PointeurTxt\Char
Else
c.l = 128 | (*PointeurTxt\Char & 127)
EndIf
If Debut = #Vrai
If c = 32 ; ESPACE
Espace_HTML$ + " "
EndIf
If c = 9 ; TABULATION
For r.l = 1 To 10
Espace_HTML$ + " "
Next
EndIf
If c = 13 ; A LA LIGNE
TexteHTML + "<div> </div>"
EndIf
If c > 32 ; TEXTE
Debut = #Faux
EndIf
EndIf
If Debut = #Faux
If c = 13 ; A LA LIGNE
TexteHTML + "<div>" + Espace_HTML$ + Trim(Ligne_de_txt$) + "</div>"
Espace_HTML$ = ""
Ligne_de_txt$ = ""
Debut.b = #Vrai
EndIf
If c >= 32 ; ON RECUPERE LE TEXTE
Ligne_de_txt$ + Chr(c)
If t = LongueurTxt ; FIN DU FICHIER TEXTE
TexteHTML + "<div>" + Espace_HTML$ + Trim(Ligne_de_txt$) + "</div>"
EndIf
EndIf
EndIf
*PointeurTxt + 1
Next
TexteHTML + "</td>"
TexteHTML + "</tr>"
TexteHTML + "</table>"
TexteHTML + "</body>"
TexteHTML + "</html>"
ProcedureReturn TexteHTML
EndProcedure
Texte.s = "Kcc" + Chr(13) + "Mange des sucettes"
OpenWindow(0,0,0,600,300,"WebGadget",#PB_Window_SystemMenu)
WebGadget(0,10,10,580,280,"")
RetourTexteHTML$ = ConvertTxtEnHtml(Texte.s, 10, RGB(0,0,255), RGB(0,0,255))
SetGadgetItemText(0, #PB_Web_HtmlCode, RetourTexteHTML$)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
End