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

Hospital Room Assignment

Started by 99jeep, 19 August 2013 - 02:39 PM
99jeep #1
Posted 19 August 2013 - 04:39 PM
I'm trying to create a hospital room system that will allow the user, while in the menu to see who's in the room, and also while entering in the room #, see the information of the person. Here's what I have so far.

Program is called rooms


term.clear ()
term.setCursorPos (1, 1)
print ("Hospital Emergency Rooms")
print ("")
print ("[T 1]	 "..name1)
print ("")
print ("[T 2]	 "..name2)
print ("")
print ("[TR 1]   "..name3)
print ("")
print ("[TR 2]   "..name4)
print ("")
print ("[TR 3]   "..name5)
print ("")
print ("[TR 4]   "..name6)
print ("")
print ("[OR 1]   "..name7)
print ("")
print ("[OR 2]   "..name8)
term.setCursorPos (1, 18)
input = read ()
if input == "t1" then
while true do --to start a loop
term.clear ()
term.setCursorPos (1, 1)
print ("Triage Room 1")
print ("")
write ("Enter Patients Name: ")
name1 = read ()
term.setCursorPos (1, 1)
print ("Enter Patients Name: "..name1) -- This is so it appears that after I hit enter, the next field will pop up without any noticeable transition in the program
write ("Enter Date of Birth: ")
dob1 = read ()
term.setCursorPos (1, 2)
print ("Enter Date of Birth: "..dob1)
write ("Enter Condition Code: ")
con1 = read ()
term.setCursorPos (1, 3)
print ("Enter Condition Code: "..con1)
sleep (1) -- For better flow of data entry
term.setCursorPos (1, 7)
print ("Is information Correct? [Y/N]")
local event, param1 = os.pullEvent "char"
if param1 == "y" then
term.setCursorPos (1, 7)
print ("Information Verified. Data Saved for "..name1)
sleep (2)
shell.run ("rooms")
break
elseif param1 == "n" then
term.setCursorPos (1, 7)
print ("Re-Enter Information and Verify")
sleep (2)

And this code will continue for all rooms. Now I thought I had it because after entering the fields of data, when it did shell.run ("rooms") the data that I entered for name1 appeared in the field print ("[T 1] "..name1) so it looked like this.


Emergency Rooms

[T 1] Steve Stevenson

[T 2]
etc…

And when I entered nothing in the fields for name1, it appeared blank indicating the room is unoccupied (meaning I just kept hitting enter when asked to enter name, dob, and condition thereby the computer thought the data entered was a space). Now I already know the issue with my code. Upon start-up of the program from a reboot, the program is looking for data entered for name1 and if there is none , a concatenate error will appear for line 5. And at this point I have looked at others coding trying to make hotels, but I have not been able to figure this out, and being a novice computercraft player, I am not aware of all of LUA's capabilities. I hope someone can help me with this. Thanks much.
Edited by
Lyqyd #2
Posted 19 August 2013 - 07:57 PM
Split into new topic.
Zudo #3
Posted 20 August 2013 - 04:20 PM
print ("Is information Correct? [Y/N]

Er… no
99jeep #4
Posted 20 August 2013 - 04:53 PM
print ("Is information Correct? [Y/N]

Er… no
sorry, fixed that.