check = fs.exists("test")am I able to run check or do I have to do this with a function? I was just wondering because a 1 line function just seems odd to me.
#1
Posted 21 January 2013 - 01:41 PM
#2
Posted 21 January 2013 - 03:18 PM
#3
Posted 21 January 2013 - 03:22 PM
Lyqyd, on 21 January 2013 - 03:18 PM, said:
He is most likely using it in this context:
if check == true then --do something with the "test" file else --create the "test" file end
EDIT: Would be nice to see the code for better understanding
#4
Posted 21 January 2013 - 04:06 PM
#5
Posted 21 January 2013 - 06:33 PM
check = fs.exists("disk") while check == false do print("Insert Disk") sleep(1) check --would I be able to do this? endOr would I have to make 'check' a function and call it. I would want to use this for checking if a disk is in a disk drive.
#6
Posted 21 January 2013 - 06:44 PM
function checkDisk() if fs.exists("disk") then return true else return false end end check = false while check == false do print("Insert Disk") sleep(1) check = checkDisk() end
#7
Posted 21 January 2013 - 06:46 PM
#9
Posted 21 January 2013 - 06:49 PM
brett122798, on 21 January 2013 - 06:44 PM, said:
function checkDisk() if fs.exists("disk") then return true else return false end end check = false while check == false do print("Insert Disk") sleep(1) check = checkDisk() end
Whoa, seriously? Why not just this:
while not fs.exists("disk") do print("Insert Disk") sleep(1) end
#10
Posted 21 January 2013 - 06:52 PM
Lyqyd, on 21 January 2013 - 06:49 PM, said:
brett122798, on 21 January 2013 - 06:44 PM, said:
function checkDisk() if fs.exists("disk") then return true else return false end end check = false while check == false do print("Insert Disk") sleep(1) check = checkDisk() end
Whoa, seriously? Why not just this:
while not fs.exists("disk") do print("Insert Disk") sleep(1) end
#11
Posted 21 January 2013 - 07:01 PM
Lyqyd, on 21 January 2013 - 06:49 PM, said:
brett122798, on 21 January 2013 - 06:44 PM, said:
function checkDisk() if fs.exists("disk") then return true else return false end end check = false while check == false do print("Insert Disk") sleep(1) check = checkDisk() end
Whoa, seriously? Why not just this:
while not fs.exists("disk") do print("Insert Disk") sleep(1) end
#12
Posted 21 January 2013 - 07:05 PM
grand_mind1, on 21 January 2013 - 06:52 PM, said:
While loops check the conditional before the loop begins each time it loops, so whenever "disk" came into existence, the conditional would change and the loop would exit at that time.
#13
Posted 21 January 2013 - 07:12 PM
Lyqyd, on 21 January 2013 - 07:05 PM, said:
grand_mind1, on 21 January 2013 - 06:52 PM, said:
While loops check the conditional before the loop begins each time it loops, so whenever "disk" came into existence, the conditional would change and the loop would exit at that time.
#14
Posted 21 January 2013 - 07:16 PM
grand_mind1, on 21 January 2013 - 07:12 PM, said:
As stated the while loop checks the conditional before running the instructions. A for loop does the same. It checks the conditional before executing the instructions.
However a repeat loop is different. A repeat loop will always performs the instructions at least once before checking the conditional. Repeat loop syntax:
repeat -- code to repeat until <some condition>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users