-1

If I declare integers before task main() in ROBOTC those integers would be in the global scope? Therefore, I would be able to call them out at any time; however, I plan to create other tasks and void functions before my task main(). Would the integers I create, their placement would have to be directly underneath the pragma statements?

#pragma  config(Motor, mtr_S1_C1_1, motorRight, tmotorNormal, PIDControl)
#pragma config(Motor, mtr_S1_C1_2, motorLeft, tmotorNormal, PIDControl)

/* Initialized Integer Placement*/

task main(){
motor[motorLeft] = 50; // Half power
motor[motorRight] = 50;
wait1Msec(1000); // One second
motor[motorLeft] = 0; // Stop
motor[motorRight] = 0;
}
EnlightenedFunky
  • 303
  • 1
  • 13
  • Why do you mean by the pragma statement ? `#pragma once`, `#pragma pack`, etc..... variable made outside any function are global and are normally stored in the data segment. and can be accessed anywhere. – Noctisdark Oct 15 '16 at 15:43
  • @Noctisdark You have never programmed with ROBOTC? Therefore it does not behoove you to comment, because even in an intro ROBOTC course they teach what a pragma statement. It's the statements that declare the motors and the sensors, and so on. I would not need to include that in the question because I tagged ROBOTC anybody with programming in ROBOTC would know that. The person who answered my question knew that. – EnlightenedFunky Jun 02 '20 at 15:40
  • @Noctisdark https://stemrobotics.cs.pdx.edu/sites/default/files/RobotC-Motors.pdf – EnlightenedFunky Jun 02 '20 at 15:48
  • you're right and the guilt is coming after me 7 years later – Noctisdark Jan 03 '23 at 22:17

1 Answers1

1

Yes, they would be globals, which you can use in any of your functions. Be careful not to create any local variables inside your functions by the same name as it could cause problems.

mberna
  • 313
  • 5
  • 18