Simple Login System - Tutorial not working as described

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
livemilan
Posts: 2
Joined: Mon Jan 20, 2014 3:14 pm

Simple Login System - Tutorial not working as described

Post by livemilan » Mon Jan 20, 2014 3:26 pm

Hi,

I wonder if someone can shed some light on the above tutorial, which I was trying out, but it does not behave as described. I have created the main stack and two cards with the code as described, but it does not seem to work as seen in the tutorial example. The code that does not seem to execute is:

local sUsername, sPassword

on openCard
put "johnsmith" into sUsername
put "pa55word" into sPassword
end openCard

on loginCheck
if field "username" is sUsername and field "password" is sPassword then
answer "Login Successful"
go to card "accessed"
else
answer "Details Incorrect. Please try again!"
end if
end loginCheck

but if I replace the code with:

local sUsername, sPassword

on openCard
put "johnsmith" into sUsername
put "pa55word" into sPassword
end openCard

on mousedown
if field "username" is sUsername and field "password" is sPassword then
answer "Login Successful"
go to card "accessed"
else
answer "Details Incorrect. Please try again!"
end if
end mousedown

Is this correct or is there something that I am missing or mis-understanding.

Code base : livecode - community
Version : 6.5.1
Platform : windows 7

Thanks,
Milan

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Simple Login System - Tutorial not working as described

Post by Klaus » Mon Jan 20, 2014 3:40 pm

Hi Milan,

1. welcome tot he forum :D

2. Plase always add links or hints on where to find themto mentioned tutorials etc..,
we may not know wath you are talking about!

3. "does not seem to work" is a very lame error description 8)
What happens? Do you always see "Details Incorrect. Please try again!"?

4. You wrote: "but if I replace the code with:" but you did not finish that sentence 8)

5. Do you have your "mousedown" handler in the card script or ina button on the card?
In that case you need to make the variables global to be abble to access them in the button script, too!

BUT why not use the first script: "on opencard" and the "logincheck" in the card and simply execute the logincheck in the button?

Card script:

Code: Select all

local sUsername, sPassword

on openCard
  put "johnsmith" into sUsername
  put "pa55word" into sPassword
end openCard

on loginCheck
  if field "username" is sUsername and field "password" is sPassword then
    answer "Login Successful"
    go to card "accessed"
  else
    answer "Details Incorrect. Please try again!"
  end if
end loginCheck
Button script:

Code: Select all

on mousedown
  logincheck
end mousedown
:D


Best

Klaus

livemilan
Posts: 2
Joined: Mon Jan 20, 2014 3:14 pm

Re: Simple Login System - Tutorial not working as described

Post by livemilan » Mon Jan 20, 2014 7:43 pm

Hi Klaus,

Thank you for the pointers. I will remember this, hopefully, for other postings.

You have answered my intended question, but just so that others can know my answers to your valid questions they are :

2) see http: lessons;runrev;com|s|lessons|m|2592|l|137217-simple-login-system ( I had lots of issues trying to add so I have coded ; => . and | => /)
3) Agreed I was being kind. It DOES NOT work. Nothing happens (no message is displayed) before and when the login button is pressed whether I entered a correct username and password or not.
4) The sentence is complete with the code replacement below the sentence, which just replaced the logincheck handler with the mousedown handler.
5) I put the mousedown in the same card script (Login card) (just to see where the problem was)

I like your proposal of executing the logincheck in the button, but as I am new and following an example, I did not think beyond just getting an example to work to aid my understanding of livecode. I think you will agree that the tutorial needs updating to reflect what you are indicating or otherwise just to demonstrate a working sample. What is best practice regarding the scripting and execution for making it easily maintainable in livecode?

I hope this helps.

BTW For some reason it did not let me reply with repeated message that I did not have permission to do so. Got the following message:

"Your account does not have permission to post links or domain/page references" but url is on and img is on. So I had to recode the url.

Thanks,
Milan

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Simple Login System - Tutorial not working as described

Post by LCNeil » Mon Jan 20, 2014 8:06 pm

Hi Livemilan,

As Klaus suggested, you can call the loginCheck from the button in question but this has been omitted from the lesson. Apologies for any confusion this has caused.

I have updated the lesson to reflect this change.

Kind Regards,

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com

Post Reply