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

problem need help

Started by dum b, 30 March 2015 - 11:48 PM
dum b #1
Posted 31 March 2015 - 01:48 AM
so have a problem with my startyp on my computer and need help

rs.getInput("left")
os.run("Birthday")
end

so my error is this weridness

[string"startup"]:3: '<eof>' expected
Lupus590 #2
Posted 31 March 2015 - 02:05 AM
remove line 3, files don't need "end" to mark the end (the <eof> character does this - this is added by the OS for you)

Also, in case you have not noticed, questions like this go in the "ask a pro" section of the forums and it helps if you give the post a more descriptive title
Edited on 31 March 2015 - 12:08 AM
KingofGamesYami #3
Posted 31 March 2015 - 02:55 AM
I remember when I did that… took me three weeks to figure out what I was doing wrong.

Anyway, end doesn't mean the end of the file, it means the end of a statement, for example:


if var == "hi" then
  --#do stuff
end --#you add an end here to end the if statment

while true do
  --#stuff
end --#you add an end here to end the while loop

Basically, it tells the interpreter "after this point, code will not be in the last statement"
Konlab #4
Posted 31 March 2015 - 01:24 PM
I think you want to run the Birthday only when it's redstone signal on the left. In this case you need an if statement:

if rs.getInput("left") then
Lupus590 #5
Posted 31 March 2015 - 03:09 PM
if you are putting in the if statement, then you will need to leave the "end" at the end

Complete code will be:

if rs.getInput("left") then
   shell.run("Birthday") --#was os.run("Birthday"), this causes problems with environments I believe. edit2: yes, see wiki
end

edit: change to shell.run

edit2: http://computercraft.info/wiki/Os.run
Edited on 31 March 2015 - 02:35 PM
MKlegoman357 #6
Posted 31 March 2015 - 04:29 PM
And to add to all of that code, you'd probably want to use shell.run instead of os.run.


if rs.getInput("left") then
   shell.run("Birthday")
end