Just starting out? Need help? Post your questions and find answers here.
TheMexican
 
Posts: 17
Joined: Sun Jun 07, 2015 5:58 pm

IF...ENDIF issue

by TheMexican Wed Dec 27, 2017 12:32 am

I don't understand why this code doesn't work. The issue is on the Procedure btnLogin_Action() If statement on line 39. I cannot get it to be true.

Probably some stupid mistake
Code: Select all
EnableExplicit

Global validuser.a = 0

; ------------- Connects to Employees Collection on Restdb.io --------------------------


Enumeration Windows
  #wndLogin
  #wndMain
EndEnumeration

Enumeration myGadgets
  #txtLoginUsername
  #txtLoginPassword
  #strLoginUsername
  #strLoginPassword
  #btnLogin
EndEnumeration

Enumeration myFonts
  #Arial16B
  #Arial16
EndEnumeration

;----------- Declares --------------------------------
Declare ShowLogin()
Declare btnLogin_Action()
Declare ShowMainWindow()

;------------ Gadget Callbacks ----------------------

Procedure btnLogin_Action()
  Debug GetGadgetText(#strLoginUsername)
  Debug GetGadgetText(#strLoginPassword)
  If Trim(GetGadgetText(#strLoginUsername)) = "test" And Trim(GetGadgetText(#strLoginPassword)) = "test1123"  ; < ---------Issue is here
    CloseWindow(#wndLogin)
    ShowMainWindow()
  Else
    !alert("Invalid Username/Password");
  EndIf
 
EndProcedure


Procedure ShowMainWindow()
  If OpenWindow(#wndMain,0,0,600,500,"Employee Directory",#PB_Window_ScreenCentered)
   
  EndIf
 
EndProcedure

Procedure ShowLogin()
 
  If OpenWindow(#wndLogin,0,0,400,200,"Employee Directory",#PB_Window_ScreenCentered)
    SetWindowColor(#wndLogin,RGB(255, 222, 173))
   
    TextGadget(#txtLoginUsername,10,50,100,25,"Username:",#PB_Text_Right)
    StringGadget(#strLoginUsername,120,45,200,25,"")
   
    TextGadget(#txtLoginPassword,10,75,100,25,"Password:",#PB_Text_Right)
    StringGadget(#strLoginPassword,120,70,200,25,"",#PB_String_Password)
   
    ButtonGadget(#btnLogin,150,125,100,25,"Login")
    BindGadgetEvent(#btnLogin,@btnLogin_Action())
   
    LoadFont(#Arial16,"Arial",16)
    SetGadgetFont(#txtLoginUsername,FontID(#Arial16))
    SetGadgetFont(#txtLoginPassword,FontID(#Arial16))
   
    SetGadgetFont(#strLoginUsername,FontID(#Arial16))
    SetGadgetFont(#strLoginPassword,FontID(#Arial16))
   
    SetActiveGadget(#strLoginUsername)
 
  EndIf

 
EndProcedure




;--- Start Main Program ---------------------
ShowLogin()

User avatar
Peter
 
Posts: 497
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: IF...ENDIF issue

by Peter Wed Dec 27, 2017 2:14 am

no problem here.

Note, that the password is 'test1123' (not 'test123')

Greetings ... Peter

P.S.: The login data should not be stored in the code
TheMexican
 
Posts: 17
Joined: Sun Jun 07, 2015 5:58 pm

Re: IF...ENDIF issue

by TheMexican Wed Dec 27, 2017 5:06 pm

:oops: :oops: :oops: :oops: :oops: :oops: :oops:

I feel the pain of embarrassment !!
User avatar
Peter
 
Posts: 497
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: IF...ENDIF issue

by Peter Wed Dec 27, 2017 8:13 pm

Image
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 2 guests