Jump to content




Program Selector



  • You cannot reply to this topic
5 replies to this topic

#1 Silent_Devil

  • Members
  • 10 posts

Posted 06 July 2015 - 03:33 AM

I don't know if this is the right area because i'm new to this site but I really need some help with my startup program I am making for my pocket computer

Basically, this program is meant to run a program that the user specifies form the list of available programs but whenever I try to run a program, I just get the message: "bios:365 Expected string,string".

Here is the code:

pastebin get Z8T25RQa

It would mean a lot to get some help in this!

Thank you in advance!

~Silent_Devil

P.S: I'm kind of a n00b at programming, but if you want to see the code for the 2 available programs I'm trying to get this one to run, just ask ;)

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 06 July 2015 - 04:25 AM

Moved to Ask a Pro.

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 06 July 2015 - 06:56 AM

Quote

if input == "Door" then
os.run(Door)

elseif

input == "Lift" then
os.run(Lift)

Two points - Lift and "Lift" are not the same, and that's not how you use os.run(). You might be better off using shell.run() instead.

#4 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 06 July 2015 - 06:58 AM

First thing I'd like to point out is your formatting isn't very good. Which is fine, since you are just getting into programming :)
Extra spaces or enters don't change how the code works, but makes it much easier to read

Like this:
Spoiler


Now, for the error

Errors like that can be really annoying, since they don't seem to have anything to do with your code
(You can actually look at the bios.lua file to get an idea of what is wrong, if you have to)

In this case, this is your problem:
if input == "Door" then
  os.run(Door)			   --# This line
elseif
  input == "Lift" then
  os.run(Lift)				 --# And this line
else
  os.reboot()
end

Instead of passing a string (In quotes), you pass a variable (No quotes).
Since you never set 'Door' or 'Lift' to anything, you are passing nil, which confuses os.run()

Also, like Bomb Bloke said, you should be using shell.run(), not os.run(). Similar name, very different use.

Edited by HPWebcamAble, 06 July 2015 - 06:59 AM.


#5 meigrafd

  • Members
  • 17 posts
  • LocationGermany

Posted 06 July 2015 - 11:41 AM

I think you currently also dont need the function 'Option()' and instead of quoting somthing in 'shell.run()' you can also use the input Variable

Something like this:

Spoiler


#6 Silent_Devil

  • Members
  • 10 posts

Posted 06 July 2015 - 12:18 PM

Everyone, thank you for your feedback! I knew I had to use something like os.run() but I couldn't remember the proper name for it! And thank you all for your tips as they have been very useful to me and I will take them all on board! I will try and sort my scripts in a more organized manner. And as for the function I only put that there because it was easier for me to do that ad it works logically for me... But that's just my mindset! :3 once again, thank you everyone for your help and quick responses, it really means a lot to me!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users