Author Topic: A simple command line tool translating DEF FN functions into FUNCTIONs  (Read 6524 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Moreover it seems that you can read variables from main module into DEF Fn
run this code in Qbasic
Code: Text: [Select]
  1. DEF FnQbasicVariableScope(z%)
  2.  c = 1
  3. FnQbasicVariableScope= 1+ z%
  4. PRINT a%, b%, c
  5. END DEF
  6.  
  7.  
  8. a% = 10
  9. b% = FnQbasicVariableScope (20)
  10. PRINT a%,b%,c
  11. END
  12.  
and you'll get this result
Quote
10      0       1
10     21       1
so DEF_FN can read directly variables in main module and main module can read directly variables in DEF_FN:
it seems more a GOSUB than a separated function.
With the addition of the bug that lets declare a variable in DEFFN by DIM before to declare the same variable by assignment statement into main module.

Now we can begin to understand why Galleon doesn't like to support DEF FN in QB64 and also why the same developers of QB and Qbasic warning to modify variable of main from DEF_FN or make operations or graphic work .


 
Programming isn't difficult, only it's  consuming time and coffee