[Solved] Cc1.56 "atm" Accounts...
Goof
31 Aug 2013
Just to note:
THIS IS SOLVED
Hello im trying to make a program that displays the Cash of the current account etc... but i've ran into a problem... or maybe its a bug with the CC 1.56.
It seems like the if statement is still bypassing the statement when AccountMenu is false...
I know i could've made the == true and == false different...
but i just want to know if i've made something wrong with this if statement.. because i cant see it...
Full Code of the full API- Program- etc:
I know theres many bugs as far... but im still working on the whole project... so dont think this code is close to done
IF any has any idea of why and how then please tell me
Old Thread:
Thanks in Advance
THIS IS SOLVED
Hello im trying to make a program that displays the Cash of the current account etc... but i've ran into a problem... or maybe its a bug with the CC 1.56.
It seems like the if statement is still bypassing the statement when AccountMenu is false...
if accountMenu == true and loggedBalance == false and loggedSettings == false and balanceWithdraw == false or balanceDeposit == false then
I know i could've made the == true and == false different...
but i just want to know if i've made something wrong with this if statement.. because i cant see it...
Full Code of the full API- Program- etc:
Spoiler
I know theres many bugs as far... but im still working on the whole project... so dont think this code is close to done
IF any has any idea of why and how then please tell me

Old Thread:
Spoiler
Thanks in Advance
LBPHacker
31 Aug 2013
string.gmatch returns an iterator. You need string.find:
EDIT: Added ^ and $ anchors.
local _, _, first, second = string.find(msg, "^(%w+)&pwd=(%w+)$")
EDIT: Added ^ and $ anchors.
floppyjack
31 Aug 2013
LBPHacker, on 31 August 2013 - 07:19 AM, said:
string.gmatch returns an iterator. You need string.find:
EDIT: Added ^ and $ anchors.
local _, _, first, second = string.find(msg, "^(%w+)&pwd=(%w+)$")
EDIT: Added ^ and $ anchors.
Just for completion:
You can use string.match instead so you don't have to throw away any variables:
local first, second = string.match(msg, "(%w+)&pwd=(%w+)")
LBPHacker
31 Aug 2013
Goof
31 Aug 2013
Hello everyone...
I've found an issue i cannot solve just out of my mind... (im totally confused)
code is an API:
Error is in the Topic Title
If anyone want to help me, then please comment
Thanks in Advance
I've found an issue i cannot solve just out of my mind... (im totally confused)
code is an API:
function isPermitted(name, pass) local failRead = fs.open(".accounts", "r") local failRd = failRead.readAll() failRead.close() if not string.find(failRd, "failSafe") then local failSafe = fs.open(".accounts", "a") failSafe.writeLine("failsafe") failSafe.close() end local rRead = fs.open(".accounts", "r") local rAll = rRead.readAll() rRead.close() print(tostring(rAll)) if string.find(rAll, "&usr="..name.."&pwd="..pass) then return true else return false end end
Error is in the Topic Title
If anyone want to help me, then please comment

Thanks in Advance
Bubba
31 Aug 2013
You really should use pastebin and give use the entire code.
That being said, my guess is that you are passing in invalid parameters to the function. The only place within the function that you use concatenation is here:
So either name or pass must be nil. Check your usage again.
That being said, my guess is that you are passing in invalid parameters to the function. The only place within the function that you use concatenation is here:
if string.find(rAll, "&usr="..name.."&pwd="..pass) then
So either name or pass must be nil. Check your usage again.
Goof
31 Aug 2013
my program : http://pastebin.com/FbWTR1VC
my API: http://pastebin.com/Xzqd4gS0
EDIT: and btw.. i dont see any nil parametres... i think i have to make a whole debug hour....
EDIT2: Nevermind.. i figured it out:
changed
my API: http://pastebin.com/Xzqd4gS0
EDIT: and btw.. i dont see any nil parametres... i think i have to make a whole debug hour....

EDIT2: Nevermind.. i figured it out:
changed
local _, _, user, pass = string.find(msg, "^(%w+)&pwd=(%w+)*")to
local _, _, user, pass = string.find(msg, "(%w+)&pwd=(%w+)")
Bubba
31 Aug 2013
The error probably occurs here (line 12 of the actual program):
My guess is that the message is not correctly formed and the string.find does not return the proper values. What message is being sent to the program?
Also, please keep questions about the same program in the same thread. I've merged them, but just keep that in mind. Thanks.
local _, _, user, pass = string.find(msg, "^(%w+)&pwd=(%w+)$")
My guess is that the message is not correctly formed and the string.find does not return the proper values. What message is being sent to the program?
Also, please keep questions about the same program in the same thread. I've merged them, but just keep that in mind. Thanks.
Goof
02 Sep 2013
Ehh. as you said, then i did what you wanted...
Heres a new bug for the program... Please help me, again
- Edited OP
Thanks in Advance
Heres a new bug for the program... Please help me, again

- Edited OP
Thanks in Advance
GopherAtl
03 Sep 2013
"and" has higher precedence than "or," just like * has higher precedence than +.
So your long condition, "accountMenu == true and loggedBalance == false and loggedSettings == false and balanceWithdraw == false or balanceDeposit == false", the checks for accountMenu through balanceWithdraw all get reduced to a single true/false if all are true or not, and then that is or'd with balanceWithdraw, so if balanceWidthdraw is false, the condition will run, regardless of any other conditions.
Use () to group them and force the intended order of evaluation.
So your long condition, "accountMenu == true and loggedBalance == false and loggedSettings == false and balanceWithdraw == false or balanceDeposit == false", the checks for accountMenu through balanceWithdraw all get reduced to a single true/false if all are true or not, and then that is or'd with balanceWithdraw, so if balanceWidthdraw is false, the condition will run, regardless of any other conditions.
Use () to group them and force the intended order of evaluation.
Goof
03 Sep 2013
Oh... derpy derp.
my brain is so derpy stupid....
ofc i had to use parantheses... well Thanks very much for helping my brain xD
Thanks
my brain is so derpy stupid....
ofc i had to use parantheses... well Thanks very much for helping my brain xD
Thanks
