die Function hat mein programm geschrottet ?!

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

Sephka

Betreff: die Function hat mein programm geschrottet ?!

BeitragMo, Jul 26, 2010 19:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich habe eine Funktion gemacht die Pausen macht.Und jetzt treten folgende Probleme auf:
1.Color 0,255,0
Print "Password correctly."
Print "Access allowed."
wird nicht mehr angezeigt wenn das PW richtig ist.
2. Das Pogramm zeigt obwohl das PW richtig ist das es falsch ist
vor der funktion war alles normal. Crying or Very sad Crying or Very sad
Danke für die hilfe schonmal iom vorraus!!
Der Code
Code: [AUSKLAPPEN]
;________________________________
;|Password Input - Version 1.00 |
;|by Sephka - 2010              |
;|______________________________| 
Graphics 500,150,16,2
SetBuffer BackBuffer()
;Variables
Global PW$
Global CPrinttext$
Global antwort$,backtime = MilliSecs(),ccolor,stern$
Global timer = MilliSecs()
Text_an = False
Text_Zeit = MilliSecs()
;Functions
Function newinput$(x1,y1,x2,y2,frage$,maxl)
   a = GetKey()
   If a => 32 And a <= 255 And Len(antwort$) <= maxl-1 Then antwort$ = antwort$ + Chr$(a)
   If KeyDown(28) Then Return antwort$
   If KeyDown(14) Or KeyDown(203) And Len(antwort$) > 0 And MilliSecs()-backtime > 125 Then
      antwort$ = Left(antwort$,(Len(antwort$)-1))
      backtime = MilliSecs()
   End If

   Color 25,100,200
   Rect x1, y1,x2-x1, y2-y1,1
   Color 10,50,150
   Rect x1, y1,x2-x1, y2-y1,0
   textlange = StringWidth(antwort$) 
   texthohe = StringHeight(antwort$)
   fragelange = StringWidth(frage$)
   Color 0,50,ccolor
   Rect x1+28+(Len(antwort$)*8),y1+4,10,texthohe-1,1
   ccolor = ccolor + 5
   If ccolor = 255 Then ccolor = 100
   Color 255,255,255
stern$ = Replace(LSet ("",Len(antwort$))," ","*")
  Text x1+3,y1+3, frage$ + " " + stern$
  End Function
;####################################################
Function wait(ttime)
timer = MilliSecs()
Repeat
Until timer + ttime = MilliSecs()
End Function
;Password retrieval
  Repeat
 Repeat
  Cls
 
 Color 255,0,0
  If MilliSecs()-500>Text_Zeit
      Text_an=1-Text_an
      Text_Zeit = MilliSecs()
   EndIf
   If Text_an Then Text 0,0,"Password needed!",0,0
 
 PW = newinput$(1,14,90,33,"->",6)

   Flip
 Until KeyDown(28)
   Cls
   
If PW = "sephka" Then
 Color 255,255,255
 Locate 1,1
 Print "Password confirmed."
 Flip
 wait(1000)
 Color 0,255,0
 Print "Password correctly."
 Print "Access allowed."
 Flip
 wait(1000)
Else Color 255,0,0
 Locate 1,1
 Print "Error:Access denied!"
 Flip
 wait(2000)
 
EndIf
Until PW = "sephka"
End

derAtomkeks

ehemals "Sethus"

BeitragMo, Jul 26, 2010 19:37
Antworten mit Zitat
Benutzer-Profile anzeigen
Das Problem ist, dass du zwei Mal überprüfst, ob Enter gedrückt wurde. Wenn man Enter zufälligerweise (was anscheinend immer ist) nach dem Funktionsaufruf und vor dem Schleifenende drückt, dann ist PW$ immernoch leer, da die Funktion den Tastendruck nicht mitbekommen hat, und die Schleife ist zuende. Mach lieber Until PW$ <> "", da dies nur der Fall ist, wenn Enter gedrück wurde.

Sephka

BeitragMo, Jul 26, 2010 19:50
Antworten mit Zitat
Benutzer-Profile anzeigen
Gelöst,danke.
 

Sterbendes Lüftlein

BeitragDi, Aug 10, 2010 19:40
Antworten mit Zitat
Benutzer-Profile anzeigen
Text entfernt

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group