Skip to main content

[Migrated content. Thread originally posted on 24 April 2012]

Hi ((:

I'm trying to write a program, but the compiler give me an error in following line of code, and I do not know why :X


       class-id assembler public.
       
       01 CurrentNdx binary-long.
       01 AsLength binary-short unsigned.
       01 IsEnd condition-value.
       01 ExecutionAddress binary-short unsigned.
       
       method-id Main static.
       01 LabelTable type System.Collections.Hashtable.
       procedure division using by value Args as string occurs any.
              set LabelTable to new System.Collections.Hashtable(50).
             
              *> Error here
              set IsEnd to false.
             
       end method Main.
       
       enum-id. Reg private.
           78 Unknown value 0.
           78 A value 4.
           78 B value 2.
           78 D value 1.
           78 X value 16.
           78 Y value 8.
       end enum Reg.
       
       end class assembler


Thanks
Alexandre

[Migrated content. Thread originally posted on 24 April 2012]

Hi ((:

I'm trying to write a program, but the compiler give me an error in following line of code, and I do not know why :X


       class-id assembler public.
       
       01 CurrentNdx binary-long.
       01 AsLength binary-short unsigned.
       01 IsEnd condition-value.
       01 ExecutionAddress binary-short unsigned.
       
       method-id Main static.
       01 LabelTable type System.Collections.Hashtable.
       procedure division using by value Args as string occurs any.
              set LabelTable to new System.Collections.Hashtable(50).
             
              *> Error here
              set IsEnd to false.
             
       end method Main.
       
       enum-id. Reg private.
           78 Unknown value 0.
           78 A value 4.
           78 B value 2.
           78 D value 1.
           78 X value 16.
           78 Y value 8.
       end enum Reg.
       
       end class assembler


Thanks
Alexandre
By default, data items in the class working-storage section are assumed to be instance data and therefore cannot be accessed from a static method such as your Main.

In order to access IsEnd from a static method you need to make it into static data.
You can do this by adding the static keyword to its definition:

01 IsEnd condition-value static.

or you can define a static section in your program so that everything contained in it will be defined as static:


       class-id assembler public.
       static.
       01 CurrentNdx binary-long.
       01 AsLength binary-short unsigned.       
       01 IsEnd condition-value.       
       01 ExecutionAddress binary-short unsigned.             
       method-id Main static.       
       01 LabelTable type System.Collections.Hashtable.       
       procedure division using by value Args as string occurs any.             
          set LabelTable to new System.Collections.Hashtable(50).                           
          *> Error here             
          set IsEnd to false.                     
       end method Main.
       end static.             
       enum-id. Reg private.           
       78 Unknown value 0.           
       78 A value 4.           
       78 B value 2.           
       78 D value 1.           
       78 X value 16.           
       78 Y value 8.       
       end enum Reg.             
       end class assembler.