Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Frank Brübach on January 12, 2025, 02:41:11 PM

Title: Module question
Post by: Frank Brübach on January 12, 2025, 02:41:11 PM
'
hello charles, this o2 code example about inner-modules and macro prefixes doesnt work here, have you another one for me
how that's working ? thanks

'
$ client ...
int x=0
print client.x '0 'error

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 "not ok"

' thx frank
Title: Re: Module question
Post by: Charles Pegge on January 12, 2025, 11:08:23 PM
This is derived from a nested namespace experiment from inf/testlog3.02bas (2022).

client only needs an extra dot to make it work in the current o2 :)

$ client ....
int x=0
print client.x

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

The problem is we don't yet have a good use-case for nested namespaces.
Title: Re: Module question
Post by: Frank Brübach on January 13, 2025, 12:27:57 PM

thank you charles, didn't know yet this example
 learning new things again ;)

 how would this example below looks like with a module prefix macro?

'
module

  namespace abc
  uses console
  end namespace
 
$ client ....
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

end module

' thanks, frank

where would you use this kind of module feature with oxygen?
Title: Re: Module question
Post by: Charles Pegge on January 13, 2025, 04:24:32 PM
module currently has a null definition but you could use it like this:

'Supposing you wanted to create a module
'to contain all the core Windows calls:
======
module
======
% win windows..
namespace windows
uses corewin
end namespace
==========
end module
==========
'
'test
win.beep(432,500)
win.sleep(1000)
print "ok"
Title: Re: Module question
Post by: Frank Brübach on January 13, 2025, 08:30:28 PM
Yes I understand thanks..

' test module feature go, frank
'
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