Author Topic: #case how to end or better yet how to end blocks in general  (Read 3000 times)

0 Members and 1 Guest are viewing this topic.

kryton9

  • Guest
In the help it states:  #case has block scope and reverts to its previous state when the block ends.

How do you end a block?

Charles Pegge

  • Guest
Re: #case how to end or better yet how to end blocks in general
« Reply #1 on: June 20, 2011, 01:45:32 AM »

All functions,subs and methods, and control structures are blocks. Any entity defined within these is invisible to the outside. You can also define a scope explicitly.

Code: [Select]
scope(
....
...
)

The work 'block' may also be used. Or even a left bracket on its own.

I found #case capital to be most useful. Capitalised equates and types seem to be common practice in C,  to distinguish from other entities of the same name.

Charles

kryton9

  • Guest
Re: #case how to end or better yet how to end blocks in general
« Reply #2 on: June 20, 2011, 03:26:02 AM »
A simple example. This is cool Charles, I like it :)
Code: OxygenBasic
  1. scope(
  2. #case capital
  3.         int I = 17
  4.         int i = 76
  5.  
  6.         print "I    " I   '17
  7.         print "i    " i   '76
  8.  
  9.         int NUMBER = 8943
  10.         int Number = 25
  11.         int number = 42
  12.  
  13.         print "NUMBER    " NUMBER   '8943
  14.         print "Number    " Number   '42
  15.         print "number    " number   '42
  16. )
  17.  
  18.  
  19. scope(
  20. #case insensitive
  21.         int I = 17
  22.         int i = 76
  23.  
  24.         print "I    " I   '76
  25.         print "i    " i   '76
  26.  
  27.         int NUMBER = 8943
  28.         int Number = 25
  29.         int number = 42
  30.  
  31.         print "NUMBER    " NUMBER   '42
  32.         print "Number    " Number   '42
  33.         print "number    " number   '42
  34. )
  35.  
  36. scope(
  37. #case sensitive
  38.         int I = 17
  39.         int i = 76
  40.  
  41.         print "I    " I   '17
  42.         print "i    " i   '76
  43.  
  44.         int NUMBER = 8943
  45.         int Number = 25
  46.         int number = 42
  47.  
  48.         print "NUMBER    " NUMBER   '8943
  49.         print "Number    " Number   '25
  50.         print "number    " number   '42
  51. )
« Last Edit: June 20, 2011, 03:36:55 AM by kryton9 »