Publié : jeu. 26/juil./2007 15:48
........
Forums PureBasic - Français
https://www.purebasic.fr/french/
Code : Tout sélectionner
Procedure erreur()
MessageRequester("info","erreeeeeeeuuuuuuuuuuuur")
EndProcedure
OnErrorGosub(@erreur())
a = a / 0
ha oui ! quel ane !!Mytic a écrit :Nooooon c’était pas un bug , le problème venait des ( )
pour la relecture, c'est quand même plus sympath d'avoir les procédures en bas de listing , car sinon sur de gros projet, durant le Scrolling on se colle une bonne centaines de lignes de Procédure avant , d'enfin arriver a la boucle principale !!Ollivier a écrit : Sinon je rejoins un peu Dobro pour l'ordre des choses. J'ai du mal quand toutes mes "Global", "Declaration", "Procedure" ne sont pas ensemble
Code : Tout sélectionner
Global Texte$
Declare Graph()
Declare zone_texte(x.l,Y.l,Couleur.l)
Declare.S Curs(ms.L, Char.S = "_")
InitSprite ()
InitKeyboard ()
OpenWindow (0,0,0,300,300, "" )
OpenWindowedScreen ( WindowID (0),0,0,300,300,0,0,0)
Texte$ = "A>"
Repeat
Graph()
FlipBuffers ()
Event = WindowEvent ()
Until Event = #PB_Event_CloseWindow
Procedure zone_texte(x.l,Y.l,Couleur.l)
ExamineKeyboard()
Texte$ = Left(Texte$, Len(Texte$) - KeyboardReleased( #PB_Key_Back ) ) + KeyboardInkey ()
DrawingMode(#PB_2DDrawing_Transparent)
DrawText (x+2,Y+2,texte$ + Curs(500),#Black,0)
DrawText (x,Y,texte$ + Curs(500),Couleur,0)
EndProcedure
Procedure Graph()
StartDrawing ( ScreenOutput ())
xc = 1
yc = 1
For Rayon = 400 To 10 Step -10
Circle (xc, yc, Rayon , RGB ( Random (255), Random (255), Random (255)))
Next Rayon
zone_texte(10,10,#White)
StopDrawing ()
EndProcedure
Procedure.S Curs(ms.L, Char.S = "_")
Static Used.L
Static Start.L
Static CursorStat.B
If Used = 0: Start = ElapsedMilliseconds(): Used = 1: EndIf
If ElapsedMilliseconds() > Start + ms
CursorStat = 1 - CursorStat
Used = 0
EndIf
If CursorStat
ExitChar.S = Char
Else
ExitChar = ""
EndIf
ProcedureReturn ExitChar
EndProcedure
Code : Tout sélectionner
Global MaxText.L
MaxText = 15
Global Dim Texte$(MaxText)
Global Ptr.L
Declare Graph()
Declare zone_texte(x.l,Y.l,Couleur.l)
Declare.S Curs(ms.L, Char.S = "_")
InitSprite ()
InitKeyboard ()
OpenWindow (0,0,0,300,300, "" )
OpenWindowedScreen ( WindowID (0),0,0,300,300,0,0,0)
Texte$(0) = "Ecrit et appuie sur [Entrée]"
Ptr = 1
Repeat
Graph()
FlipBuffers ()
Event = WindowEvent ()
Until Event = #PB_Event_CloseWindow
Procedure zone_texte(x.l,Y.l,Couleur.l)
ExamineKeyboard()
Texte$(Ptr) = Left(Texte$(Ptr), Len(Texte$(Ptr) ) - KeyboardReleased( #PB_Key_Back ) ) + KeyboardInkey ()
If KeyboardReleased(#PB_Key_Return)
Ptr + 1
If Ptr > MaxText
Ptr = MaxText
For i = 0 To MaxText - 1
Texte$(i) = Texte$(i + 1)
Next i
Texte$(MaxText) = ""
EndIf
EndIf
DrawingMode(#PB_2DDrawing_Transparent)
For i = 0 To MaxText
If i = Ptr
DrawText (x+2,Y+2+i*16,texte$(i) + Curs(500),#Black,0)
DrawText (x,Y+i*16,texte$(i) + Curs(500),Couleur,0)
Else
DrawText (x+2,Y+2+i*16,texte$(i),#Black,0)
DrawText (x,Y+i*16,texte$(i),Couleur,0)
EndIf
Next i
EndProcedure
Procedure Graph()
StartDrawing ( ScreenOutput ())
xc = 1
yc = 1
For Rayon = 400 To 10 Step -10
Circle (xc, yc, Rayon , RGB ( Random (255), Random (255), Random (255)))
Next Rayon
zone_texte(10,10,#White)
StopDrawing ()
EndProcedure
Procedure.S Curs(ms.L, Char.S = "_")
Static Used.L
Static Start.L
Static CursorStat.B
If Used = 0: Start = ElapsedMilliseconds(): Used = 1: EndIf
If ElapsedMilliseconds() > Start + ms
CursorStat = 1 - CursorStat
Used = 0
EndIf
If CursorStat
ExitChar.S = Char
Else
ExitChar = ""
EndIf
ProcedureReturn ExitChar
EndProcedure
Code : Tout sélectionner
Global MaxText.L
MaxText = 15
Global Dim Keyb.L(255)
Global Dim KeybStart.L(255)
Global Dim Texte$(MaxText)
Global Ptr.L
Declare Graph()
Declare zone_texte(x.l,Y.l,Couleur.l)
Declare.S Curs(ms.L = 200, Char.S = "_")
Declare.L Keyboard(Touche.L, AttenteIni.L = 500)
InitSprite ()
InitKeyboard ()
LoadFont(0, "Verdana", 12, #PB_Font_Italic| #PB_Font_Bold)
OpenWindow (0,0,0,300,300, "" )
OpenWindowedScreen ( WindowID (0),0,0,300,300,0,0,0)
Texte$(0) = "Ecrit et appuie sur [Entrée]"
Ptr = 1
Repeat
Graph()
FlipBuffers ()
Event = WindowEvent ()
Until Event = #PB_Event_CloseWindow
Procedure zone_texte(x.l,Y.l,Couleur.l)
ExamineKeyboard()
Texte$(Ptr) = Left(Texte$(Ptr), Len(Texte$(Ptr) ) - Keyboard( #PB_Key_Back ) ) + KeyboardInkey ()
If Keyboard(#PB_Key_Return)
Ptr + 1
If Ptr > MaxText
Ptr = MaxText
For i = 0 To MaxText - 1
Texte$(i) = Texte$(i + 1)
Next i
Texte$(MaxText) = ""
EndIf
EndIf
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(0) )
th = TextHeight("A")
For i = 0 To MaxText
If i = Ptr
DrawText (x+2,Y+2+i*th,texte$(i) + Curs(),#Black,0)
DrawText (x,Y+i*th,texte$(i) + Curs(),Couleur,0)
Else
DrawText (x+2,Y+2+i*th,texte$(i),#Black,0)
DrawText (x,Y+i*th,texte$(i),Couleur,0)
EndIf
Next i
EndProcedure
Procedure Graph()
StartDrawing ( ScreenOutput ())
xc = 1
yc = 1
For Rayon = 400 To 10 Step -10
Circle (xc, yc, Rayon , RGB ( Random (255), Random (255), Random (255)))
Next Rayon
zone_texte(10,10,#White)
StopDrawing ()
EndProcedure
Procedure.S Curs(ms.L = 200, Char.S = "_")
Static Used.L
Static Start.L
Static CursorStat.B
If Used = 0: Start = ElapsedMilliseconds(): Used = 1: EndIf
If ElapsedMilliseconds() > Start + ms
CursorStat = 1 - CursorStat
Used = 0
EndIf
If CursorStat
ExitChar.S = Char
Else
ExitChar = ""
EndIf
ProcedureReturn ExitChar
EndProcedure
Procedure.L Keyboard(Touche.L, AttenteIni.L = 500)
Static Used.L
Static Start.L
Static CursorStat.B
Signal = 0
If KeyboardPushed(Touche)
If Keyb(Touche) = 0
Keyb(Touche) = 1
KeybStart(Touche) = ElapsedMilliseconds()
Signal = 1
Else
If ElapsedMilliseconds() > KeybStart(Touche) + AttenteIni
Signal = 1
EndIf
EndIf
Else
Keyb(Touche) = 0
EndIf
ProcedureReturn Signal
EndProcedure
Code : Tout sélectionner
Global MaxText.L
MaxText = 15
Global Dim Keyb.L(255)
Global Dim KeybStart.L(255)
Global Dim Texte$(MaxText)
Global Ptr.L
Declare Graph()
Declare zone_texte(x.l,Y.l,Couleur.l)
Declare.S Curs(ms.L = 200, Char.S = "_")
Declare.L Keyboard(Touche.L, AttenteIni.L = 500)
InitSprite ()
InitKeyboard ()
LoadFont(0, "Verdana", 12, #PB_Font_Italic| #PB_Font_Bold)
OpenWindow (0,0,0,300,300, "" )
OpenWindowedScreen ( WindowID (0),0,0,300,300,0,0,0)
Texte$(0) = "Ecrit et appuie sur [Entrée]"
Ptr = 1
Repeat
Graph()
FlipBuffers ()
Event = WindowEvent ()
Until Event = #PB_Event_CloseWindow
Procedure zone_texte(x.l,Y.l,Couleur.l)
ExamineKeyboard()
Texte$(Ptr) = Left(Texte$(Ptr), Len(Texte$(Ptr) ) - Keyboard( #PB_Key_Back ) ) + KeyboardInkey ()
If Keyboard(#PB_Key_Return)
Ptr + 1
If Ptr > MaxText
Ptr = MaxText
For i = 0 To MaxText - 1
Texte$(i) = Texte$(i + 1)
Next i
Texte$(MaxText) = ""
EndIf
EndIf
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(0) )
th = TextHeight("A")
For i = 0 To MaxText
If i = Ptr
DrawText (x+2,Y+2+i*th,texte$(i) + Curs(),#Black,0)
DrawText (x,Y+i*th,texte$(i) + Curs(),Couleur,0)
Else
DrawText (x+2,Y+2+i*th,texte$(i),#Black,0)
DrawText (x,Y+i*th,texte$(i),Couleur,0)
EndIf
Next i
EndProcedure
Procedure Graph()
Static a.L
If a = 0
a = 1
CreateSprite(0, 100, 100)
StartDrawing (SpriteOutput(0))
Box(1, 1, 90, 90, #Red)
StopDrawing()
EndIf
StartDrawing ( ScreenOutput ())
xc = 1
yc = 1
For Rayon = 400 To 10 Step -10
Circle (xc, yc, Rayon , RGB ( Random (255), Random (255), Random (255)))
Next Rayon
DisplaySprite(0, 0, 0)
zone_texte(10,10,#White)
StopDrawing ()
EndProcedure
Procedure.S Curs(ms.L = 200, Char.S = "_")
Static Used.L
Static Start.L
Static CursorStat.B
If Used = 0: Start = ElapsedMilliseconds(): Used = 1: EndIf
If ElapsedMilliseconds() > Start + ms
CursorStat = 1 - CursorStat
Used = 0
EndIf
If CursorStat
ExitChar.S = Char
Else
ExitChar = ""
EndIf
ProcedureReturn ExitChar
EndProcedure
Procedure.L Keyboard(Touche.L, AttenteIni.L = 500)
Static Used.L
Static Start.L
Static CursorStat.B
Signal = 0
If KeyboardPushed(Touche)
If Keyb(Touche) = 0
Keyb(Touche) = 1
KeybStart(Touche) = ElapsedMilliseconds()
Signal = 1
Else
If ElapsedMilliseconds() > KeybStart(Touche) + AttenteIni
Signal = 1
EndIf
EndIf
Else
Keyb(Touche) = 0
EndIf
ProcedureReturn Signal
EndProcedure