Menu

no detect a variable not declared

Manuel
2016-09-27
2016-09-28
  • Manuel

    Manuel - 2016-09-27

    if I write an expression like this

    jojo=jojo

    without having declared it "jojo" does not fail.

    but if I create a function called "mostrar_01"

    and I write "jojo = mostrar_o1" the compiler does not show errors

     
  • Anobium

    Anobium - 2016-09-27

    Correct Both are assignments.

    What do you think should be happening?

     
  • Manuel

    Manuel - 2016-09-27

    if I do not declare a variable or constant or mistakenly write the name of a function the compiler should not accept its use in the program.
    It is right?

     
    • Anobium

      Anobium - 2016-09-28

      This is correct. Great Cow BASIC creates byte variables automatically. A function typically returns a byte value. The typo simply creates a variable.

      We are improving this operation but the current release does not fully support #option explicit.

       
  • Manuel

    Manuel - 2016-09-28

    the undeclared variable can be a variable typed wrongly.
    This can be a disaster in monitoring long programs

    dim palabra as Word
    dim cadena as string
    dim simply as Byte

    ' the variable "casoid" is not declared

    palabra=casoid
    casoid= palabra * 10
    palabra= casoid

    do forever

    loop

    for casoid =1 to 100
    palabra=palabra+1
    next casoid

    end

     
    • Anobium

      Anobium - 2016-09-28

      Yes. Type very carefully. :-) You can inspect the generated ASM for variable surprises. In the example below CASOID is defined.

      ;Set aside memory locations for variables
      CADENA  EQU 453
      CASOID  EQU 32
      PALABRA EQU 33
      PALABRA_H EQU 34
      SIMPLY  EQU 35
      SYSBYTETEMPX  EQU 112
      SYSDIVMULTA EQU 119
      SYSDIVMULTA_H EQU 120
      SYSDIVMULTB EQU 123
      SYSDIVMULTB_H EQU 124
      SYSDIVMULTX EQU 114
      SYSDIVMULTX_H EQU 115
      SYSTEMP1  EQU 36
      SYSTEMP1_H  EQU 37
      SYSWORDTEMPA  EQU 117
      SYSWORDTEMPA_H  EQU 118
      SYSWORDTEMPB  EQU 121
      SYSWORDTEMPB_H  EQU 122
      SYSWORDTEMPX  EQU 112
      SYSWORDTEMPX_H  EQU 113
      

      On a serious note. We are addressing this by adding #option explicit. Do try - but, do not post issues until we formally release the capability.

      If I use #option explicit on your example. I get the correct warning.

      New15.gcb (24): Error: Variable CASOID was not explicitly declared
      
       
  • Manuel

    Manuel - 2016-09-28

    ok
    thank you

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.