Previous Next        Current Page: NeXtMidas Training / Primitives / Lab 1 / Solution
back
+ Start Here   
+ Background   
+ Common Midas Concepts   
+ Getting Started - Part 1   
+ Getting Started - Part 2   
+ Working with Files   
+ Option Trees   
+ Macros - Part 1 (Basics)   
+ Macros - Part 2 (Graphics)   
+ NetBeans - Part 1 (Setup)   
+ NetBeans - Part 2 (GUIs)   
+ NetBeans - Part 3 (Profiler)   
+ Eclipse - Part 1 (Setup)   
+ Eclipse - Part 2 (GUIs)   
- Primitives   
   + Overview   
   + Open, Process, Close   
   + Building   
   + The NeXtMidas API   
   - Lab 1   
      - Instructions   
      - Solution   
   + Special Variables   
   + Lab 2   
   + Lab 3*   
   + Files in a Primitive   
   + Lab 4   
   + Lab 5*   
   + Test Macros   
   + Lab 6   
   + Real Time Controls   
   + Lab 7   
   + Working with Messages   
   + Lab 8   
   + Primitive Restarts   
   + Introduction to DSP   
   + Lab 9   
   - Commands executing commands   
+ WebStart   
+ Maps & Imagery   
+ X-Midas Interoperability   
+ RMIF & Remoting   
+ Installing NeXtMidas   
+ Support & Maintenance   
+ File Handlers   


  • Lab 1: (Solution)
    • Take a look at the full solution.
    • An alternate solution for process() is as follows:
        public int process() {
          M.info("inside process() count="+count);
          count = count + 1;
      
          if (count > 20) {
            return FINISH;
          } else {
            return NORMAL;
          }
        }
      • While this alternate solution is technically correct, it is discouraged.
        • Return statements inside an if statement are hard to debug once the primitive gets complicated.
        • It is best to declare a status variable at the top of the method with a default value (usually NORMAL) and altering it as needed.

back