Oxygen Basic

Information => Development => Topic started by: Emil_halim on March 22, 2013, 12:28:04 AM

Title: PlugIn system for Oxygen basic
Post by: Emil_halim on March 22, 2013, 12:28:04 AM
Hi Charles ,

I just want to know somethings , you include the source code of Oxygen , is this for developers so they make a changes or what.

BTW BCX has a plugin system called a preprocessor  and activated bu $PP switch , it is actually a dll that will
be loaded when switch is on and in main Parser bcx read the line / word then passes it to a PreProcess Function in the dll , the function will modify the line / word  and return it back to BCX to handle it as usual.   

the advantage is that developer can extend Oxygen without touching Oxygen at all.

so what do you think?

 Emil .   
Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 22, 2013, 02:41:47 AM
Hi Emil,

I provide the OxygenBasic source code as a resource :)

You can create your own compiler with language extension, or a completely new language using the oxygen DLL, by translating source code into an Oxygen format. So no need to break into O2 source, which is likely to go through many more transformations over the next few years.

Oxygen has a lot of parsing tools, locked inside. I plan to expose some of these for compiler pre-parsing of source code.

Charles
Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 22, 2013, 09:53:08 AM

okay ,

Here is my first attempt to make HighLevelAsm with Oxygen.

it is actually a PerProcessor tool that handle the hieh level asm then it calls gxo2 to compile it.

Here is an Example

Code: [Select]
indexbase 0
$ filename "test3c.exe"
#include "..\..\inc\RTL32.inc"

zstring a[]="ABCDE"
zstring b[]="12345"

Sub H_strcpy(zstring dst,src)
 #HLAsm {
     uses edx ebx
     Eax = dst
     Edx = src
     .repeat
          CL = char[Edx]
          char[Eax] = CL
          Eax++
          Edx++
          CL = char[Edx]     
     .until  CL != 0
  }
End Sub

H_strcpy(&a,&b)
print a

as you can see the switch for preprocesse is  #HLAsm inclused between {  } .

any comment are welcome , will post the too later.
Title: Re: PlugIn system for Oxygen basic
Post by: Aurel on March 22, 2013, 01:54:36 PM
Emil..
May i ask you stupid question about this HLA .
/because i love ask stupid questions.. ;D/
what is the main point - speed or optimization or both ?
And if - in which type of programs ?
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 22, 2013, 02:53:01 PM
Quote
what is the main point - speed or optimization or both ?
  Neither.

As the name suggests, High Level ASM unless you enjoy Low Level ASM and BrainFuck is your high level language of choice.

Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 22, 2013, 03:13:12 PM
O2 now uses an intermediate language to express abstract assembly code instructions, rather like Java byte code. This is then translated into Assembly code instructions. It is not quite the same thing as a high level assembler, but it serves an important role in aiding production of device-independent Asm, and some optimisation as well.

Simple example (with some artistic licence  :) ):

Code: OxygenBasic
  1. /*
  2.   BASIC
  3. */
  4.  
  5. sys a,b
  6. float c
  7.  
  8. a=b+c
  9.  
  10. /*
  11.  
  12.   ABSTRACT INSTRUCTIONS
  13.  
  14.   (user friendly translation)
  15.  
  16.   static   int       a
  17.   static   int       b
  18.   static   float     c
  19.   load     int       b
  20.   convert  float,int
  21.   add      float     c
  22.   convert  int,float
  23.   store    int       a
  24.  
  25. */
  26.  
  27.  
  28. /*
  29.  
  30.   X86 ASSEMBLY CODE
  31.  
  32.   mov eax,[ebx+0x1004]
  33.   'CONVERT CPU TO FPU
  34.  push eax
  35.   fild dword [esp]
  36.   add esp,4
  37.   fadd dword [ebx+0x1008]
  38.   'CONVERT FPU TO CPU
  39.  sub esp,4
  40.   fistp dword [esp]
  41.   pop eax
  42.   mov [ebx+0x1000],eax
  43.  
  44. */
  45.  

Charles
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 22, 2013, 03:23:04 PM
Code: OxygenBasic
  1.   (user friendly translation)
  2.  
  3.   static   int       a
  4.   static   int       b
  5.   static   float     c
  6.   load     int       b
  7.   convert  float,int
  8.   add      float     c
  9.   convert  int,float
  10.   store    int       a
  11.  

That is very cool Charles. What are you going to name this intermediate ASM helper language?

A+B might be a good name.  ;D
Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 22, 2013, 03:31:11 PM
OIL OxygenBasic Intermediate language  ;D

It only exists in machine-friendly form at present, but it could be made accessible.
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 22, 2013, 03:51:23 PM
Quote
OIL OxygenBasic Intermediate language

You have my vote, it's a winner!
Title: Re: PlugIn system for Oxygen basic
Post by: Aurel on March 22, 2013, 10:37:03 PM
Quote
and BrainFuck is your high level language of choice.

and maybe you can stop eat the shit,and use your freakin SB( shit basic)... ;D
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 22, 2013, 11:38:33 PM
Hey Charles, how about putting Aurel on ice for awhile until he promises to get along with others.

I don't think Charles would have put the extraordinary effort into ScriptBasic if he thought the language had no marit.

Aurel's childish comments are hurting the project and chasing away talent that is hard to find. His contributions have been buggy and blames everyone else for his failures. I feel sorry for the fool as he is missing an opportunity to learn from others much farther down the road.



Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 23, 2013, 12:12:44 AM

Gentlemen please! Be kind to each other.

To answer Aurel's original question, I would say that A high level assembler is somewhere between a normal programming language and traditional Assembler. You can get slightly better performance, and still have something that is easier to read block structure than the list format of Assembly code.

BF is a difficult language, unfriendly to both man and machine. The name itself is a warning to all who use it!
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 23, 2013, 12:29:25 AM
Quote
BF is a difficult language, unfriendly to both man and machine. The name itself is a warning to all who use it!

That may be true but I solved that issue long ago with my BF2SB converter (http://www.allbasic.info/mboard/index.php?topic=653.msg2106#msg2106).  8)

Code: [Select]
jrs@laptop:~/sb/sb22/test$ time scriba skitri.sb
                                *    
                               * *    
                              *   *    
                             * * * *    
                            *       *    
                           * *     * *    
                          *   *   *   *    
                         * * * * * * * *    
                        *               *    
                       * *             * *    
                      *   *           *   *    
                     * * * *         * * * *    
                    *       *       *       *    
                   * *     * *     * *     * *    
                  *   *   *   *   *   *   *   *    
                 * * * * * * * * * * * * * * * *    
                *                               *    
               * *                             * *    
              *   *                           *   *    
             * * * *                         * * * *    
            *       *                       *       *    
           * *     * *                     * *     * *    
          *   *   *   *                   *   *   *   *    
         * * * * * * * *                 * * * * * * * *    
        *               *               *               *    
       * *             * *             * *             * *    
      *   *           *   *           *   *           *   *    
     * * * *         * * * *         * * * *         * * * *    
    *       *       *       *       *       *       *       *    
   * *     * *     * *     * *     * *     * *     * *     * *    
  *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *    
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *    

skitri.sb (converted by BF2SB)
Code: [Select]
SPLITA STRING(30000,48) BY "" TO memory
WHILE memory[cellptr] > 0
  memory[cellptr] -= 1
  IF memory[cellptr] = 10 THEN
    PRINTNL
  ELSE
    PRINT CHR(memory[cellptr])
  END IF
WEND
cellptr += 1
memory[cellptr] += 4
WHILE memory[cellptr] > 0
  cellptr -= 1
  memory[cellptr] += 8
  cellptr += 1
  memory[cellptr] -= 1
WEND
cellptr += 1
memory[cellptr] += 8
WHILE memory[cellptr] > 0
  cellptr += 1
  memory[cellptr] += 4
  cellptr -= 1
  memory[cellptr] -= 1
WEND
cellptr += 2
memory[cellptr] += 2
cellptr += 3
memory[cellptr] += 1
cellptr += 3
memory[cellptr] += 1
cellptr -= 10
WHILE memory[cellptr] > 0
  memory[cellptr] -= 1
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
    cellptr += 1
    memory[cellptr] += 1
    cellptr -= 1
  WEND
  cellptr += 1
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
    cellptr -= 1
    memory[cellptr] += 1
    cellptr += 3
    IF memory[cellptr] = 10 THEN
      PRINTNL
    ELSE
      PRINT CHR(memory[cellptr])
    END IF
    cellptr -= 2
  WEND
  cellptr += 3
  WHILE memory[cellptr] > 0
    WHILE memory[cellptr] > 0
      memory[cellptr] -= 1
      cellptr += 1
      memory[cellptr] += 8
      WHILE memory[cellptr] > 0
        cellptr += 1
        memory[cellptr] += 4
        cellptr -= 1
        memory[cellptr] -= 1
      WEND
      cellptr += 1
      IF memory[cellptr] = 10 THEN
        PRINTNL
      ELSE
        PRINT CHR(memory[cellptr])
      END IF
      cellptr -= 2
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr += 1
        memory[cellptr] += 1
        cellptr -= 1
      WEND
      memory[cellptr] += 1
      cellptr += 1
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr += 1
        memory[cellptr] += 10
        cellptr -= 2
        memory[cellptr] += 1
        cellptr += 1
      WEND
      cellptr += 1
      IF memory[cellptr] = 10 THEN
        PRINTNL
      ELSE
        PRINT CHR(memory[cellptr])
      END IF
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
      WEND
      cellptr += 1
    WEND
  WEND
  memory[cellptr] += 1
  cellptr -= 3
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
    WHILE memory[cellptr] > 0
      memory[cellptr] -= 1
      cellptr += 1
      memory[cellptr] += 1
      cellptr -= 1
    WEND
    memory[cellptr] += 1
    cellptr += 1
    WHILE memory[cellptr] > 0
      memory[cellptr] -= 1
      cellptr -= 1
      memory[cellptr] += 1
      cellptr += 3
      memory[cellptr] -= 1
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr += 1
        memory[cellptr] += 1
        cellptr -= 1
      WEND
      memory[cellptr] += 2
      cellptr += 1
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr -= 1
        memory[cellptr] -= 1
        cellptr += 1
      WEND
      cellptr -= 3
    WEND
    cellptr -= 4
  WEND
  memory[cellptr] += 10
  IF memory[cellptr] = 10 THEN
    PRINTNL
  ELSE
    PRINT CHR(memory[cellptr])
  END IF
  memory[cellptr] += 3
  IF memory[cellptr] = 10 THEN
    PRINTNL
  ELSE
    PRINT CHR(memory[cellptr])
  END IF
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
  WEND
  cellptr -= 1
WEND
memory[cellptr] += 5


My current laptop compared to the old P4 makes a big difference.

real   0m0.067s
user   0m0.056s
sys   0m0.012s
jrs@laptop:~/sb/sb22/test$
Title: Re: PlugIn system for Oxygen basic
Post by: Peter on March 23, 2013, 02:24:53 AM
Hi, Charles,

Could it be that there is  a bug in your last OxygenBasic Dll !
Code: [Select]
include "sw.inc"
Window 320,240,1

SetText 0, 0, GetWidth() /2, 0
SetText 0,20, GetHeight()/2, 0

SetText 0,40, GetWidth() *2, 0
SetText 0,60, GetHeight()*2, 0

SetText 0, 80, GetWidth() -20, 0
SetText 0,100, GetHeight()-20, 0

SetText 0,120, GetWidth() +20, 0
SetText 0,140, GetHeight()+20, 0

WaitKey
Quit

Sirpinsky:
Code: [Select]
indexbase 0
include "sw.inc"

Window 256,256,1
SetFont 12,24,bold,"courier"
SetCaption "Sirpinsky shake"

int numSteps=10000
float ax = 10, cy = 10
float ay = 256 - 10
float bx = 256 - 10
float by = 256 - 10
float cx = 256  / 2
float px = ax, py = ay
 
While Key(27)=0
Cls RGB 12,230,40
For n=0 To numSteps
DrawPoint px, py, 2, 2, RGB 0,0,255
Select Case Rnd(0,2)
       Case 0
          px = (px + ax) / 2
          py = (py + ay) / 2
       Case 1
          px = (px + bx) / 2
          py = (py + by) / 2
       Case 2
          px = (px + cx) / 2
          py = (py + cy) / 2
End Select          
Next
Sync
Wait 45
Wend
Quit

X
Title: Re: PlugIn system for Oxygen basic
Post by: Peter on March 23, 2013, 04:10:20 AM
Quote
Gentlemen please! Be kind to each other.

Please, more respect, we have children here!
Title: Re: PlugIn system for Oxygen basic
Post by: Aurel on March 23, 2013, 06:50:40 AM
First of all ,
i ask Charles not you ,and why you respond anyway ???
Second ..
i am here because oxygenBasic - not script basic.
And what is your contribution- nothing ...Only you have the benefit of someone else's code
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 23, 2013, 07:05:14 AM
This is a forum you idiot. If you want to address an individual, send them a PM. Is your life so bad that you believe everyone has to suffer along with you? You have trashed everyone you communicate with at some point or another. Were you a spoiled brat when you were a kid as well?
Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 23, 2013, 08:30:45 AM
hay guys

 please , can you stop this now , here we are for certain case , teach help each us , and ofcourse  respect others.

   
 
Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 23, 2013, 08:42:06 AM

Charles , nice intermediate language you are making , i think this will be more better
Quote
change that

convert  float,int

to  this

convert  float to int

Quote
I would say that A high level assembler is somewhere between a normal programming language and traditional Assembler. You can get slightly better performance, and still have something that is easier to read block structure than the list format of Assembly code.

exactly true , that is what High Level asm service for

Aurel , consider the following example , it is abs function for integer fast and readable
Quote
def  AbsI
   %1
   #HLAsm {
           eax=%1
           cdq
           xor eax,edx
           eax-=edx
  }   
end def


Jone ,
  what is BF language , i never heard about it ?

Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 23, 2013, 09:22:08 AM
Hi Charles ,

one feature that was in SphinxC-- i want to see it in OxyGen. consider the following Exm.
Code: [Select]
int fastcall strlen2(EAX)
{    
    EBX=EAX;
    while(DSBYTE[EAX] !=0 )
     {
        EAX++;
     }
    EAX -= EBX;  
}  

the fastcall in sphixc-- means that the parameters is a registers so when compiler found a call to that function , it load the registers with the value then call the function it self.

So what is your opinion ?  
  
Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 23, 2013, 01:38:55 PM
Hi Emil,

OIL (OxygenBasic Intermediate Code) is in an imaginary state at present, so there is plenty of scope for thinking about syntax.  As a compiling layer, though it is very real, specifying all operations, type conversions, call types, function headers, footers etc. There are about 40 instructions so far. But I am not sure how a programmer would benefit from using this layer. Could be an entry- point for other languages.

Oxygen has a fair amount of Macro-muscle and also a simple block structure to promote high-level assembly:
Macros are often better than attempting fast-calls. You don't have the overhead of function prologs and epilogs.

Here is a byte copy example:
with the improved addr instruction it should work with a wide range of types:

macro bytecopy(dest,src,c)
scope
let n=c 'allow functions
addr ecx,src
push ecx
addr ecx,dest
mov edi,ecx
pop esi
mov ecx,n
(
 dec ecx
 jl exit
 mov al,[esi]
 mov [edi],al
 inc esi
 inc edi
 repeat
)
end scope
end macro

'test

string a=space 12
string b="abcde"
bytecopy(a,b,len b)
print a



Charles



Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 26, 2013, 02:28:56 AM
Another kind of macro which can be used to stretch syntax is def .. end def

This is a bit like a DOS macro, using %1..%9 for parameter substitution, and %% as escape.

Here is a real example where I need to generate 16 Entry points. (These are proxy callbacks for ScriptBasic)

Each function adds an extra indexing parameter to the call, then passes it onto to function CallBackRelay.



  sys ToCallBackRelay=@CallBackRelay
  jmp fwd ncallbacks

  def CallBackChannel
  ===================
  o2 !10   'alignment to 16 byte boundaries
  f%1:
  pop eax  'pop return address from stack
  push %1  'extra param
  push eax 'put return address back onto stack
  jmp ToCallBackRelay
  end def
  '
  CallBackChannel 1
  CallBackChannel 2
  CallBackChannel 3
  CallBackChannel 4
  CallBackChannel 5
  CallBackChannel 6
  CallBackChannel 7
  CallBackChannel 8
  CallBackChannel 9
  CallBackChannel 10
  CallBackChannel 11
  CallBackChannel 12
  CallBackChannel 13
  CallBackChannel 14
  CallBackChannel 15
  CallBackChannel 16

  'itr assuming all cdecl

  ncallbacks:
  ===========
  
  sys CallBackTable[16]={@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8,
                  @f9,@f10,@f11,@f12,@f13,@f14,@f15,@f16
}
Title: Re: PlugIn system for Oxygen basic
Post by: Peter on March 26, 2013, 03:34:08 AM
It get worse than Java/Python/C/C++.  :'(
Where is the simplicity ?
Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 26, 2013, 06:06:02 AM
Giving script languages the ability to handle callbacks is one of the more complex tasks I've encountered. I  show about 1/3 of the code here. I thik the use of a macro here is justified to reduce repetitive code and potential for errors.

Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 26, 2013, 06:26:39 AM
Quote
Giving script languages the ability to handle callbacks is one of the more complex tasks I've encountered.

I have asked Peter Verhas if he could assist with finding the current executing SB object pointer. That is all I need to be able to use the existing SB API to call a SB script function and never leave the IUP main loop. (SB & IUP switch roles until the window closes)

As soon as Peter gets settled in his new place, (Zürich Switzerland) he said he would have a look and get me pointed in the right direction. You would think this would have come up long before now.

Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 26, 2013, 06:53:38 AM
That's good John, if the current pProgram could be added to the Execute-Object structure, that would help a lot, otherwise you need an extra script to pass control to the module to create a pProgram.

I assume you are catching specific callbacks in your IUP module. What I'm doing here is more of a generic solution, which require a few dirty tricks :)
Title: Re: PlugIn system for Oxygen basic
Post by: JRS on March 26, 2013, 07:32:22 AM
Quote
I assume you are catching specific callbacks in your IUP module.

I'm using the external IUP loop method of the API. (IupLoopStepWait (http://www.tecgraf.puc-rio.br/iup/en/func/iuploopstep.html)) and do  an ICALL to the user defined SUB for the event from scriba. Peter recommended I continue this path and has been reluctant with my desire to do everything in the extension module. This method also requires me to use IUP's old method of defining callbacks as the new IupSetCallback() doesn't set a critical event class variable I need for the external event handler. My current method seems to work fine but I haven't crossed over to the graphics (CD) API yet and that is where callbacks get intense.
Title: Re: PlugIn system for Oxygen basic
Post by: Peter on March 26, 2013, 08:09:20 AM
I
Quote
think the use of a macro here is justified to reduce repetitive code and potential for errors.
One man, one opinion.
Thanks Charles.
Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 26, 2013, 08:32:00 AM
Hi Charles,

yes , i think that def .. end def is a very powerful macro system .

I am willing to use it to convert some asm code from Masm forum.

any way , i am planning to make a new system for preporcesse the code  before Oxygen compiling it.

consider the following

you have a folder inside Oxygen folder and it's name is Layer , that folder will contain a dll files (layers).
so the main tool will search this folder and load all valid dlls and then call a process function that exists
in each dll (layer) one after one, each one will process the source code as it want then next one and so on...  finally the main tool will call gxo2 to make the final exe file.

this system allow every one to put his layer that will process the source code as he want.

for example , i will put a define layer which will process all #define  keyword just like c++ does before code go to gxo2.

any comments & suggestions are welcome.      
Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 26, 2013, 01:03:15 PM
Hi ,

here is my first try ,  it compiled oaky but there is no exe file very strange isn't it!!!!!!!!!!!!!!?????????
Code: [Select]

  $filename "Test.exe"
  #include "..\..\inc\RTL32.inc"
  #include "../../inc/MinWin.inc"
  
' find layer folder
'==================

bool FindLayerFolder ()
{
    WIN32_FIND_DATA f
    sys h = FindFirstFile("Layer", @f)
    if h and f.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY then return true
    return false  
}

' get files in layer folder
'==========================

int    LayerNo = 0
string LayName[20]

sub GetLayers()
    WIN32_FIND_DATA f
    sys h , e
    h = FindFirstFile("Layer/*.dll", @f)
    if h then
      do
         LayerNo++  
         LayName[LayerNo] = f.cFileName
         e=FindNextFile( h, @f )
         if e = 0 then exit do
      end do
      FindClose( h )    
    end if
end sub

' load all layers
'================
dword LayerHandle[20]
dword procStart[20]
dword procProcess[20]
dword procEnd[20]

sub LoadLayers()
    sys i
    for i = 1 to  LayerNo
       LayerHandle[i] = LoadLibrary( LayName[i] )
       procStart[i]   = GetProcAddress(LayerHandle[i],"StartLayer")
       call  procStart[i]
       procProcess[i] = GetProcAddress(LayerHandle[i],"ProcessLayer")
       procEnd[i]     = GetProcAddress(LayerHandle[i],"EndLayer")
    next
End sub

sys i
print FindLayerFolder

if FindLayerFolder() then
   GetLayers()
   for i = 1 to  LayerNo
       print  LayName[i]
   next
end if        
  
 

any help please.
Title: Re: PlugIn system for Oxygen basic
Post by: Aurel on March 26, 2013, 02:59:05 PM
Hi...
try this:
Code: [Select]
$ filename "leyer.exe"
include "RTL32.inc"
include "MinWin.inc"

of course your program leyer.o2bas must be in same folder where you create exe.
i have this in main oxygen folder with minwin.inc and rtl32.inc

and compile OK, after compile i run program and get messagebox with 0
is this ok?
Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 27, 2013, 01:55:12 AM

Quote
each one will process the source code as it want then next one and so on...

This is reminiscent of the LLVM tool chain.

LLVM (low level virtual machine) gained prominence when it was adopted by Apple for their Objective C compiler.

Compilation is split down into a series of accessible configuarable layers.

llvm.org/
Title: Re: PlugIn system for Oxygen basic
Post by: Charles Pegge on March 27, 2013, 02:47:03 AM
There is a file listing program examples/FileFuncs.o2bas, which you could adapt to your requirements.

It will support an unlimited list of files: I've cleaned it up a little here:


  $ filename "t.exe"
  '#include "../../inc/RTL32.inc"
  '#include "../../inc/RTL64.inc"
  #include "../../inc/MinWin.inc"
  #include "../../inc/FileDir.inc"

  '====
  'TEST
  '====

  zstring dirname[256]
  string filter="*.o2bas"
  string cr=chr(13,10)
  sys count
  
  '
  GetCurrentDirectory 256, @dirname
  string pr="Directory Name: " dirname cr "Filter: " filter cr cr
  pr+=GetFileList (filter,count) cr cr
  print pr count " files"
Title: Re: PlugIn system for Oxygen basic
Post by: Emil_halim on March 27, 2013, 07:58:33 AM
thanks you Aurel , Charles very much.

but i wonder what is the deffrence between those
Quote
 $filename "t.exe"
  and
  $ filename "t.exe"

also i have an other problem , see this , the dll function did not called at all !!!!!!!!!!??????
Code: [Select]



  $ filename "Test.exe"
  #include "..\..\inc\RTL32.inc"
  #include "../../inc/MinWin.inc"
  
' find layer folder
'==================

bool FindLayerFolder ()
{
    WIN32_FIND_DATA f
    sys h = FindFirstFile("Layer", @f)
    if h and f.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY then return true
    return false  
}

' get files in layer folder
'==========================

int    LayerNo = 0
string LayName[20]

sub GetLayers()
    WIN32_FIND_DATA f
    sys h , e
    h = FindFirstFile("Layer/*.dll", @f)
    if h then
      do
         LayerNo++  
         LayName[LayerNo] = f.cFileName
         e=FindNextFile( h, @f )
         if e = 0 then exit do
      end do
      FindClose( h )    
    end if
end sub

' load all layers
'================
dword LayerHandle[20]
dword procStart[20]
dword procProcess[20]
dword procEnd[20]

sub LoadLayers()
    sys i
    for i = 1 to  LayerNo
       LayerHandle[i] = LoadLibrary( LayName[i] )
       procStart[i]   = GetProcAddress(LayerHandle[i],"StartLayer")
       call procStart[i]
       procProcess[i] = GetProcAddress(LayerHandle[i],"ProcessLayer")
       procEnd[i]     = GetProcAddress(LayerHandle[i],"EndLayer")
    next
End sub

' free all layers
'================
sub FreeLayers()
    for i = 1 to  LayerNo
      call procEnd[i]
      FreeLibrary(LayerHandle[i])
    next
end sub

sys i
print FindLayerFolder

if FindLayerFolder() then
   GetLayers()
   for i = 1 to  LayerNo
       print  LayName[i]
   next
end if        
  
LoadLayers()


FreeLayers()  

and here is a test layer put it in a folder and name it a Layre

Code: [Select]

  '
  ' Layere define Example
  '
  
  $ dll
  $ filename "define.dll"
  #include "..\..\..\inc\RTL32.inc"


  ' start function
  '===============
  sub StartLayer(), export
      print "from Define start function layer"
  end sub
  
  'process function
  '================
  function ProcessLayer(string* src) as bool , export
       print "from Define process function layer"
  end function
  
  'End function
  '============
  sub EndLayer() , export
       print "from Define end function layer"
  end sub