
-----------------------------------
sylvester-27
Fri Dec 09, 2005 11:24 am

Proper School Violence Test for Gr10 Students
-----------------------------------
Heres the pictures sorry it took so long

-----------------------------------
Tony
Fri Dec 09, 2005 12:54 pm


-----------------------------------
not without pictures it doesn't.. if you're not going to upload the complete application, at least don't let the program crash in absense of some data. I especially want to see that squirrelfight.bmp

anyways, I was going to say that

var c1y, c1n, c2y, c2n, c3y, c3n, c4y, c4n, c5y, c5n, c6y, c6n, c7y, c7n, c8y, c8n : real

looks plain ugly.

-----------------------------------
codemage
Fri Dec 09, 2005 12:56 pm


-----------------------------------
It won't run without having the image files included.

If you just want people to check out your code for issues, and if the pictures aren't critical to doing the test, you can %comment out the picture drawing and upload a text-only version.

Otherwise, make the pictures available.

-----------------------------------
djlenny_3000
Fri Dec 09, 2005 1:39 pm


-----------------------------------
Try Arrays

instead of 

var c1y, c1n, c2y, c2n, c3y, c3n, c4y, c4n, c5y, c5n, c6y, c6n, c7y, c7n, c8y, c8n : real 


Try
var cy:array 1..8 of real
         var cn:array 1..8 of real


allot nicer to read in my opinion

-----------------------------------
codemage
Fri Dec 09, 2005 2:58 pm


-----------------------------------
Or have a counter to count how many people took the survey, and only record "yes" answers - preferably in an array.

That'll cut back on about half of your variables.

-----------------------------------
Cervantes
Fri Dec 09, 2005 5:32 pm


-----------------------------------
Try Arrays

instead of 

var c1y, c1n, c2y, c2n, c3y, c3n, c4y, c4n, c5y, c5n, c6y, c6n, c7y, c7n, c8y, c8n : real 


Try
var cy:array 1..8 of real
         var cn:array 1..8 of real


allot nicer to read in my opinion

var c : array 1 .. 8 of
    record
        x, y : real
    end record

[url=http://www.compsci.ca/v2/viewtopic.php?t=9636]Yuuup.

-----------------------------------
sylvester-27
Thu Dec 22, 2005 12:35 pm


-----------------------------------
i tried to use the arrays but it did not recognize it. said that the variables were not declared. also how do i zip stuff so i can put the pics in too?.

-----------------------------------
Unisyst
Thu Dec 22, 2005 1:19 pm


-----------------------------------
Right-click -> New -> Zipped folder (dont know exactly what it's called because I use WinRar).

Note: This is only for Windows XP.

-----------------------------------
sylvester-27
Wed Jan 11, 2006 10:36 am


-----------------------------------
there i put the pictures in if anyone wants them

-----------------------------------
Clayton
Wed Jan 11, 2006 7:30 pm


-----------------------------------
to declare your array simply put the array into a for ex.

var cn,cy:array 1..8 of real

for i:1..8
      cn(i):=10
      cy(i):=5
end for

give that a whirl :lol:

-----------------------------------
sylvester-27
Thu Jan 12, 2006 12:01 pm


-----------------------------------
I get how the array would work but whenever I put in an array it keeps telling me that my variables have not been declared. So i might as well just leave it as messy code if it works fine.

-----------------------------------
Delos
Thu Jan 12, 2006 3:25 pm


-----------------------------------
to declare your array simply put the array into a for ex.

var cn,cy:array 1..8 of real

for i:1..8
      cn(i):=10
      cy(i):=5
end for

give that a whirl :lol:

Not quite.  That would be how you would initialize your elements in your array.  Declaration occured at the 'var cn, cy...' part.
As for the non-declaration message, are you sure you're calling the index at the same time?


var myArray : array 1..10 of int
for i : 1 .. upper (myArray)
   myArray := Rand.Int (1, 5)
end i
% Will not work.
% However:
for i : 1..upper (myArray)
   myArray (i) := Rand.Int (1, 5)
end for
% Will work since you've actually specified which element in 'myArray' you're referring to.


A general piece of advice in cases like these is to attempt to recreate the specific error message in a much simpler piece of code.  This is particularly useful when you have masses and masses of coding to sift through - knowing about what you're looking for is like adding a strobe light to that proverbial needle in that aggrevating haystack.

wtd says it best:  "Just because you shouldn't do something, doesn't mean you shouldn't know how to."

-----------------------------------
sylvester-27
Fri Jan 13, 2006 8:40 am


-----------------------------------
there would be a simpler way to do it. I think the reason that the array doesn't work is because my variables are c1y, c1n and so on. The array won't work because
var cy, cn : array 1..8 of real
will assign the variable as cy1 and cn1. so the array would work if I wanted to go through all my code and change it.

-----------------------------------
Cervantes
Fri Jan 13, 2006 1:34 pm


-----------------------------------
No sylvester-27, arrays do work in Turing.  You're just using them wrong.  Look at the code Delos posted, or look at a tutorial (see Turing Walkthrough for link).  

If you declare an array

var cn : array 1 .. 8 of int

You don't access the elements by

cn1

cn1 is a standard variable name, and you haven't declared that variable.  Rather, you access the element of the cn array:

cn (1)

