Module example Test

Started by Frank Brübach, April 17, 2025, 07:44:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

hello charles, can you check this module example, if that's running for you with latest update?

'
' test module feature, was running some month ago
'
module
======

namespace cons
uses console
end namespace
end module

  % vcprint  ..cons..output
  % vcwait   ..cons..getkey
  % vtab     ..cons..tab

vcprint 12345678 vtab "hello steve jobs" vtab
vcprint "thank you for apple computers"
vcwait

' ends

Charles Pegge

Hi Frank,

OxygenBasic now reverts to using double colons again, since it is the standard for C languages, FreeBasic etc.

But invoking macros from outside the namespace is going to cause problems. So I suggest reopening the namespace.


' test module feature, was running some month ago
'
module
======
namespace con
uses console
end namespace
end module

con::output "hello steve jobs" tab
con::output "thank you for apple computers" cr
con::getkey

'reopen namespace to use the macros:
namespace con
print "hello steve jobs" tab
print "thank you for apple computers" cr
wait
end namespace


Frank Brübach


hello charles, so far I have understood.. prefixes aren't working in old ways anymore?
for example: $ client ... and % vcprint  ..con..output

' doesnt work anymore this way
' % vcprint  ..con..output
' % vtab     ..con..tab
' vcprint 12345678 vtab "hello steve jobs" vtab
' vcprint "hello franko"
' doesnt work anymore

solution: con::output "hello steve jobs" tab

'reopen namespace to use the macros:
namespace con
print "hello steve jobs" tab 12345678 cr
print "thank you for apple computers" cr
wait
end namespace

ok here I have noticed... thanks

question: how looks the new structure for namespace in general?
but that's not so clever to use print messages at the end again?

module
namespace x
uses console ' (for example)
end namespace
end module

x:: output "hello steve" tab

namespace x
print "hello steve" tab 123456 cr ' again, why?
wait
end namespace


2) next example how to make prefixes now run with $ client ... ?

'with macro prefixes
'Accessing parent / client symbols
'
$ client ... ' prefixes arent running ok
int x=0
print client.x '0
namespace aa
  int x=2
  print client.x '0
  namespace bb
    int x=4
    print client.x '2
    namespace cc
      int x=6
      print client.x '4
    end namespace
    'print ..cc..x '6
  end namespace
end namespace

print "ok"


thanks, frank

Charles Pegge

That won't work any more, but nested namespaces are still supported:

int i=0
namespace  aa
  int i=1
  namespace bb
    int i=2
  end namespace 'bb
end namespace 'aa

print i '0
print aa::i '1
print aa::bb::i '2

Another feature of the new nested namespaces is automatic access to the parent namespace, without using a prefix.

namespace  aa
  int k=10
  namespace bb
    int i=1
    print k+i '11
  end namespace 'bb
end namespace 'aa