Computer Science Canada

Gettings values to stay on a chart

Author:  KawaNinja [ Sat Jan 31, 2004 11:26 am ]
Post subject:  Gettings values to stay on a chart

Hey, I was just starting this program to calculate the RPM/speed/torque of a cars preformance, and when I tell it to write the values on the chart on the screen, it never stays there and once it shows it, it disappears Confused and also when it is writing down the values it is flashing, and i tried the View.Set ("graphics:offscreenonly") and the View.Update but it still did it... any ideas how to correct these? Laughing

Author:  Thuged_Out_G [ Sat Jan 31, 2004 11:34 am ]
Post subject: 

well if you have the new turing, you can use View.UpdateArea(x,y,x1,y1) to jut update a certain area, and your values wont stay on screen because you must be using a cls after you put them to the screen

Author:  KawaNinja [ Sat Jan 31, 2004 11:41 am ]
Post subject: 

hmm.. I tried that View.UpdateArea code, never worked. and i dont have a cls in my loop for it.. but the thing is, when it runs through the values only one column stays up there, which is the most recent written code and the others stay up there (but flashing) for the time that it runs through the values... its sort of hard to explain what it does Sad

Author:  KawaNinja [ Sat Jan 31, 2004 12:11 pm ]
Post subject: 

I have a feeling this is something really easy, but since im a n00b at turing i cant seem to crack it Embarassed

Author:  Tony [ Sat Jan 31, 2004 12:27 pm ]
Post subject: 

it would help to see your output code Thinking no need for the full program (cuz if you post a lot of code, not many people will bother reading it). Just the part of the code that has the put statements for your chart.

Author:  Cervantes [ Sat Jan 31, 2004 12:43 pm ]
Post subject: 

View.Set ("graphics:offscreenonly") doesn't work.
the correct syntax is
code:
View.Set ("offscreenonly")

if you want something else in there (ie graphics), separate with a comma.
code:
View.Set ("graphics:500;400,offscreenonly")




below is just something interesting I've noticed about View.Update and "offscreenonly"

try this:
code:
View.Set ("offscreenonly")
put "hey"

no view.Update, but still outputs it


however, if you do this
code:
View.Set ("offscreenonly")
loop
    put "hey"
end loop

it won't output it. it needs a View.Update..

strange huh?

Author:  McKenzie [ Sat Jan 31, 2004 5:46 pm ]
Post subject: 

D'OC Student? Anyways, attach the code, I'll look at it.

Author:  Cervantes [ Sat Jan 31, 2004 6:12 pm ]
Post subject: 

McKenzie wrote:
D'OC Student


is that where you teach? and who are you talking to? Confused

Author:  McKenzie [ Sat Jan 31, 2004 6:23 pm ]
Post subject: 

Talking to kawaNinja. I used to Teach in Ajax (In Windsor now) at D'OC. The computer teacher at D'OC is still a very good friend of mine.

Author:  Andy [ Sat Jan 31, 2004 6:40 pm ]
Post subject: 

so i'm guessing he's not the moron you told us about...

Author:  McKenzie [ Sat Jan 31, 2004 6:43 pm ]
Post subject: 

No He's my student though (He has a marketing degree, I taught him to program, taught him MTG too Wink , I also taught him that guardians can out-range 'goons")

Author:  Andy [ Sat Jan 31, 2004 6:46 pm ]
Post subject: 

LOL, well teach that to mr.levack... the thinks that bunkers are "GREAT!"

Author:  Cervantes [ Sat Jan 31, 2004 7:10 pm ]
Post subject: 

haha were you playing starcraft in class? damn I wish my teacher were like you Razz he doesn't let us play games, though we do Razz (sometimes)

Author:  Andy [ Sat Jan 31, 2004 7:13 pm ]
Post subject: 

lol he doesnt let us play during class, not even during lunch anymore... after school is a different story tho

Author:  KawaNinja [ Sat Jan 31, 2004 9:10 pm ]
Post subject: 

Ok, I tried that View.Set stuff and it didnt work (the whole screen went white) but i took out the loops and it still went white.. so Confused

Quote:

D'OC Student?


and no i dont goto D'OC i goto Notre Dame.. not sure if you heard of it depending when you left (opened 3 years ago), but i know that there are quite a few teachers from D'OC that teach at my school now..
Mr O'Connor is one that i had just this past semester... when did you teach there?

And finally my code... ok this is the hard part because my code is very long.. (but in not sure if all of it is necasary because i usually always take the long way in life Rolling Eyes ), and the way its set up i pretty much have to add all of it.. anyways;

(by the way, press the UP arrow and hold it down to view the values on the chart)
code:

var chars : array char of boolean
var second : int := 0
process time_count


Input.KeyDown (chars)
delay (1000)
if chars (KEY_UP_ARROW) then
second := 1
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 2
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 3
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 4
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 5
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 6
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 7
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 8
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 9
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 10
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 11
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 12
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 13
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 14
end if
delay (1000)
if chars (KEY_UP_ARROW) then
second := 15
end if

end time_count

%%%%%%%%
%%%%%%%%

process action

loop
%ACTION BEGINS


var accel : int := 0
var rpm : int := 0
var speed : int := 0
var gear : int := 1


% UP ARROW TO ACCELERATE
Input.KeyDown (chars)
if chars (KEY_UP_ARROW)  then
accel :=  1
end if

if accel = 1 then
speed := 1
end if

% SPEED UPING IF ACCEL HELD
if second = 2 and accel = 1
then speed := 10
end if
if second = 3 and accel = 1
then speed := 25
end if
if second = 4 and accel = 1
then speed := 60
end if
if second = 5 and accel = 1
then speed := 80
end if
if second = 6 and accel = 1
then speed := 110
end if


% CALCULATING RPM
if speed = 1 then
rpm := 1000
end if
if speed = 10 then
rpm := 1800
end if
if speed = 25 then
rpm := 2300
end if
if speed = 60 then
rpm := 2900
end if
if speed = 80 then
rpm := 3500
end if
if speed = 110 then
rpm := 1500
end if

% CALCULATING GEAR
if rpm = 1000 then
gear := 1
end if
if rpm = 1800 then
gear := 1
end if
if rpm = 2300 then
gear := 1
end if
if rpm = 2900 then
gear := 1
end if
if rpm = 3500 then
gear := 1
end if
if rpm = 1500 then
gear := 2
end if


%WRITING RPM VALUE ON CHART
Text.LocateXY (250,290)
if speed = 1 then
put rpm
end if
Text.LocateXY (250,280)
if speed = 10 then
put rpm
end if
Text.LocateXY (250,270)
if speed = 25 then
put rpm
end if
Text.LocateXY (250,255)
if speed = 60 then
put rpm
end if
Text.LocateXY (250,225)
if speed = 80 then
put rpm
end if

%GEAR 2
Text.LocateXY (250,220)
if speed = 110 then
put rpm
end if

%DRAWING STATS ON CHART
Text.LocateXY (150, 290)
if second =1 then
put speed
end if
Text.LocateXY (150, 275)
if second = 2 then
put speed
end if
Text.LocateXY (150, 260)
if second = 3 then
put speed
end if
Text.LocateXY (150, 245)
if second = 4 then
put speed
end if
Text.LocateXY (150, 230)
if second = 5 then
put speed
end if
Text.LocateXY (150, 215)
if second = 6 then
put speed
end if


%DRAWING GEARS ON THE CHART
Text.LocateXY (50,290)
if rpm = 1000 then
put gear
end if
Text.LocateXY (50,275)
if rpm = 1800 then
put gear
end if
Text.LocateXY (50,260)
if rpm = 2300 then
put gear
end if
Text.LocateXY (50,245)
if rpm = 2900 then
put gear
end if
Text.LocateXY (50,230)
if rpm = 3500 then
put gear
end if
Text.LocateXY (50,215)
if rpm = 1500 then
put gear
end if


% DRAWING THE CHART
Draw.Box (0,0,400,300,7)
Draw.Line (100,0,100,300,7)
Draw.Line (200,0,200,300,7)
Draw.Line (300,0,300,300,7)
%TITLING THE CHART

Text.LocateXY (35,310) % gear
put "GEAR"
Text.LocateXY (140,310) % speed
put "SPEED"
Text.LocateXY (240,310) % rpm
put "RPM"
Text.LocateXY (330,310) % torque
put "TORQUE"

end loop
end action



fork time_count
fork action


I am terribly sorry for all this code, its just the way its setup and stuff in order to show the values on the chart.. Embarassed Crying or Very sad

Author:  recneps [ Sat Jan 31, 2004 9:22 pm ]
Post subject: 

I'm not sure if this is right, but you're putting everything, and in my experience, when you put 2 things in different x positions, and same y, they get erased because put makes a huge blank space after the word.
(I didnt have time to check the code, but i think thats whats happening) and thats not very long, ive seen longer posted Smile

Author:  KawaNinja [ Sat Jan 31, 2004 9:35 pm ]
Post subject: 

lol... yah i tried spacing out the words on the Y axis by 20 pixels apart, and it still did the same thing... Crying or Very sad why does this have to be so hard when i do it Crying or Very sad

Author:  recneps [ Sat Jan 31, 2004 9:40 pm ]
Post subject: 

try Font.Draw? I think you can use variables with that....

Author:  recneps [ Sat Jan 31, 2004 9:46 pm ]
Post subject: 

here. Font.Draw them using this, where x is your variable to be put, and font is whatever you choose Smile

code:
var x:int:=5
var font:int:=Font.New ("arial:12")
Font.Draw((intstr (x)),100,100,font,7)

Author:  KawaNinja [ Sat Jan 31, 2004 9:47 pm ]
Post subject: 

tried Font.Draw just now... it wont recognize my variable to draw on the chart, because the only thing you can put in the Font.Draw is a text string "put this" not the Font.Draw (rpm,...)
Mad
anything else lol?

Author:  recneps [ Sat Jan 31, 2004 9:51 pm ]
Post subject: 

did you read what i just posted? Smile

var x:int:=5
var font:int:=Font.New ("arial:12")
Font.Draw((intstr (x)),100,100,font,7)


intstr give you your variable (int) and turns it into a string so that font.draw can use it.

(intstr (x)) changes var x to a string. Very Happy

Author:  KawaNinja [ Sat Jan 31, 2004 9:55 pm ]
Post subject: 

aw shit ... lol i totally skipped over that part i never saw it, sorry Embarassed

Author:  recneps [ Sat Jan 31, 2004 9:55 pm ]
Post subject: 

Very Happy You're Welcome.

Author:  KawaNinja [ Sat Jan 31, 2004 10:05 pm ]
Post subject: 

OMG ! IT WORKED Very Happy lol... thanks so much man i can finally get on with this program and send it to my friend, thanks tons man!!!

Author:  Cervantes [ Sun Feb 01, 2004 11:00 am ]
Post subject: 

tony wrote:
it would help to see your output code Thinking no need for the full program (cuz if you post a lot of code, not many people will bother reading it). Just the part of the code that has the put statements for your chart.


for future reference... tony was so right, I wasn't inclined in the least to take a look at your code.

btw your sig is WAY too big... you can cut it down so there's just the motorcycle, that's still fairly big, but its toleratable. Confused

Author:  McKenzie [ Sun Feb 01, 2004 12:17 pm ]
Post subject: 

KawaNinja wrote:
when did you teach there?

I taught at D'OC from '95 to '02

By the way the easy answer to your problem, put .. after all of your put statments. (e.g. put speed -> put speed..) I know you already solved it using Font.Draw.

Author:  Cervantes [ Sun Feb 01, 2004 1:58 pm ]
Post subject: 

code:
put "hello"..

that would just make the next put statement go on the next line, does it also make it so that it doesn't fill the rest of the line up with white space?

Author:  shorthair [ Sun Feb 01, 2004 2:03 pm ]
Post subject: 

thats wouldnt put hte next put on hte next line , it would put it on the same line
code:

""..

(..) represents , stay on teh same line , good for getting user input , if your gonna put things on the same line and not use .. , then you should put them from left to right

Author:  Cervantes [ Sun Feb 01, 2004 2:23 pm ]
Post subject: 

oops I didn't mean to say that Doh!
then if you did it like that though, you'd have to do like so
code:
put " bla bla bla                            " ..

calculating the # of spaces in there.

the other way to do it is use locate and put statements so that you start at the end of the column (col not row) and work your way to the front.

Author:  McKenzie [ Sun Feb 01, 2004 3:12 pm ]
Post subject: 

err ... look at the code.
He locates before all of his puts. The result of the .. would be to prevent the \n from clearing off the rest of the line.

Author:  shorthair [ Sun Feb 01, 2004 3:26 pm ]
Post subject: 

avtually what you would wwant to do is use the repeat command , and repeat " ", ths how to do it properly ,

Author:  Cervantes [ Sun Feb 01, 2004 3:32 pm ]
Post subject: 

nono Mckenzie that's just it I didn't look at his code because it was so long Eh

Author:  recneps [ Sun Feb 01, 2004 4:46 pm ]
Post subject: 

Its fixed people, hes got it working one way. You can stop posting suggestions which he probably doesnt understand Razz


: