Warning: Illegal string offset 'html' in /home/hsn/public_html/forum/cache/skin_cache/cacheid_1/skin_topic.php on line 909

Warning: Cannot modify header information - headers already sent by (output started at /home/hsn/public_html/forum/cache/skin_cache/cacheid_1/skin_topic.php:909) in /home/hsn/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 114

Warning: Cannot modify header information - headers already sent by (output started at /home/hsn/public_html/forum/cache/skin_cache/cacheid_1/skin_topic.php:909) in /home/hsn/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 127

Warning: Cannot modify header information - headers already sent by (output started at /home/hsn/public_html/forum/cache/skin_cache/cacheid_1/skin_topic.php:909) in /home/hsn/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 136

Warning: Cannot modify header information - headers already sent by (output started at /home/hsn/public_html/forum/cache/skin_cache/cacheid_1/skin_topic.php:909) in /home/hsn/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 137

Warning: Cannot modify header information - headers already sent by (output started at /home/hsn/public_html/forum/cache/skin_cache/cacheid_1/skin_topic.php:909) in /home/hsn/public_html/forum/admin/sources/classes/output/formats/html/htmlOutput.php on line 141
Crashing Higher Computing? - HSN forum - Page 4

Jump to content


Crashing Higher Computing?


67 replies to this topic

#61 Dave

    Ruler (but not owner) of hsn

  • Moderators
  • PipPipPipPipPipPipPipPip
  • 4,252 posts
  • Location:kilmarnock(ok kilmaurs)
  • Interests:programming, exercising, brass band, using this board
  • Gender:Male

Posted 22 January 2007 - 05:09 PM

if you look at my example again you will see i have a counter variable called "x" this is what does the picking of the elements in the array

What you have written is saying "for the whole array data structure equalling 0-9 do all this other stuff"

So that is wrong you want to have For counter =0 to 9 instead there

The next problem is this line

Do while valid <> guest()

You are trying to compare a String with a Array object so you will get a data type mismatch you need to compare the variable valid with each element in the array

valid = InputBox("Ur name?")
Integer counter = 0

Do while valid <> guest(counter) OR counter<10
valid = InputBox("re-enter ur name")
loop


Just to confuse you i would do the cook like above read it and see if you understand that look at how the array is being used and the use of OR

If i am not here i am somewhere else



#62 verticalforce

    Site Swot

  • Members
  • PipPipPipPip
  • 132 posts
  • Gender:Male

Posted 22 January 2007 - 05:33 PM

Tell me if I understand this correctly:

valid = InputBox("Ur name?")
Integer counter = 0

Do while valid <> guest(counter) OR counter<10
valid = InputBox("re-enter ur name")
loop


The integer counter is set to 0 to properly intialise it at first? Since there is 9 guests, the counter is put as <10?

Why is it OR and not AND.. hmmm...

Do I have to do this whenever I loop an array?

DAMMIT lol... having a teacher who can't teach vb and don't even know vb is depressing... (he can only do BASIC and our coursework is coming shortly and we haven't revised vb for months!)

#63 verticalforce

    Site Swot

  • Members
  • PipPipPipPip
  • 132 posts
  • Gender:Male

Posted 22 January 2007 - 05:47 PM

I tried the code but got caught in the loop of death..it just kept looping at the same part although i've inputted the correct answer..

arghh... sad.gif

#64 Dave

    Ruler (but not owner) of hsn

  • Moderators
  • PipPipPipPipPipPipPipPip
  • 4,252 posts
  • Location:kilmarnock(ok kilmaurs)
  • Interests:programming, exercising, brass band, using this board
  • Gender:Male

Posted 22 January 2007 - 05:52 PM

yeh tht is why you have the infinite loop is cos o my error you should use AND

If i am not here i am somewhere else



#65 verticalforce

    Site Swot

  • Members
  • PipPipPipPip
  • 132 posts
  • Gender:Male

Posted 22 January 2007 - 06:02 PM

Thanks. It works... Lol.. that piece of programming took me ages to do and I am not even 1/20 through the program yet....

Don't worry, the code that I gave doesn't even look remotely like the coursework, only the steps are similar...

EDIT: The program works but it will only accept the first value after I retry it.. maybe this had to to with the counter = 0?

#66 verticalforce

    Site Swot

  • Members
  • PipPipPipPip
  • 132 posts
  • Gender:Male

Posted 22 January 2007 - 06:14 PM

room = InputBox("Choose a room")

Do While room < 1 Or room > 5 Or room = 3
room = InputBox("The selection might have been out of range. (Note: Room 3 is booked)")
Loop


ok, what I am trying to do here is to notify the users that room <1 or >5 is out of range and that room 3 is booked. How do I seperate these 2 things? Is it possible to do a loop in a loop? (hope this makes sense)

I am suppose to show that a room is reserved and another selection has to be made. Do I create the scenario myself or is there a proper way to do it?

#67 st-and Paul

    Top of the Class

  • Members
  • PipPipPipPipPip
  • 356 posts
  • Location:St Andrews
  • Interests:Check facebook, i cant be bothered putting them all down again :P
  • Gender:Male

Posted 22 January 2007 - 09:57 PM

It is possible to do nested loops but this makes the algorithm less efficient, avoid it if you can!

It makes more sense to loop only when the conditions arent met, so you want to do something like:

if(room > 1 && room <5)
if(room == 3) (note this double equals is just a personal thing i use in psuedocode so as not to confuse it with assignment)
print "room booked choose another"

Edit: Just ignore this, someone delete it please.

#68 verticalforce

    Site Swot

  • Members
  • PipPipPipPip
  • 132 posts
  • Gender:Male

Posted 23 January 2007 - 05:14 PM

Thanks for all of your help. I think I know enough to start my coursework now.

Thanks again.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users