This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nsl811's profile picture

Help creating my first program and got error saying

Started by nsl811, 13 July 2012 - 08:41 PM
nsl811 #1
Posted 13 July 2012 - 10:41 PM
print (" Welcome to SafeLocker v(1) ")

write " Please give a pass and user "

io.read()

write " Thankyou "

write " Insert a floppy and name it access "

print (" Checking for floppy please stand by ")

print (" Stand by……")

write " next enter a password for the security "

io.read()

x = password

if x = password (true)

print (" Security complete SafLocker v(1) setup ")

print (" Have a nice day ")

This is the code so far please help me :P/>/> this is the error bios:206: [string " safelocker " ] :21: 'then' expected
MysticT #2
Posted 13 July 2012 - 10:50 PM
if syntax:

if <condition> then
  -- code
end

if <condition> then
  -- code
else
  -- code
end

if <condition> then
  -- code
elseif <condition2> then
  -- code
end
Also, for comparations you need to use ==, not =.

So, this line:

if x = password (true)
should be:

if x == password then
And you need to add an "end" after the last print.
LucasUK #3
Posted 13 July 2012 - 10:51 PM
after an "if" you need to write "then" and finally end like so:

If "conditions" then

print xyz

else if "different conditions" then

else


End




The elseif and else are optional.
nsl811 #4
Posted 13 July 2012 - 11:00 PM
thanks it works now