Go to Post Incidentally, the best Delphi is ChiefDelphi! :) - Max Lobovsky [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 09-02-2006, 22:32
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Modified default code gives "code violation"

Quote:
Originally Posted by X-Istence
Code:
char joystick_input_2 = 0;
char drive_output = 0;
Why are these straight up char's and not unsigned?
Because of the line,
Code:
joystick_input_2 = joystick_input - 127;
joystick_input can be 0 to 255 so the result of this line can be a negative value, so the variables being assigned to must be signed.

Have you commented out the calls to SlowDrive() to prove that is where the runtime error comes from?

I don't know what this particular compiler does but I wonder about this line,
Code:
	joystick_input_2 = joystick_input - 127;
joystick_input is unsigned, so the temporary variable created is unsigned, then 127 is subtracted from that, then the temporary is assigned to joystick_input_2. Maybe that is it? To test this theory change that one line to this,
Code:
	joystick_input_2 = joystick_input;
	joystick_input_2 = joystick_input_2 - 127;
The first line handles the type change then the second line does exactly what you expect.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
default camera code edit Windward Programming 8 25-01-2006 18:33
Best Way To Insert Autonomous Code Into Default then load help.? :-)? gemccnp Programming 2 05-02-2005 18:58
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 19:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi