Aurel,
1. I got ruben2 running. The offending routine appeared to be ClearGlobalArray(). It must be commented out, otherwise the process memory gets randomly corrupted. These arrays don't require clearing at the current stage of your project development. They are filled up only once per app run and they are effectively cleared when dimensioned at app start.
I do not think it is entirely your fault; it may still be related to string memory leaks in Oxygen (see my message to Charles below).
2. ruben2 is going to be as slow as it is so long as it uses strings for all its operations. You can't improve it radically without minimizing or eliminating string operations from the loop altogether. You're using strings in very many places where you should use numeric tokens and numeric literals. Your tree runs 3.5 seconds on my PC and I think it is close to how fast it can only be until you eliminate string operations in the interpreting loop.
3. Your drawing functions are leaking GDI objects heavily. The tree generates about 7,500 orphaned pens and brushes. Please open up your Task Manager, go to View->Select Columns... and tick the GDI Objects check box. Now you will be able to see a new GDI Objects column in your table and you will be able to control the quality of drawing functions you add to ruben2.
4. Overwrite the respective functions in your ruben2 with the following code. It will prevent GDI leakage - you'll see that your tree needs only about 55 GDI objects to draw itself.
SUB LineXY (wID as INT,byval x as INT,byval y as INT,byval x1 as INT,byval y1 as INT)
hdc = GetDC(wID)
GetSize(wID,0,0,ww,hh)
int np = CreatePen(PS_SOLID,1,fColor)
int op = SelectObject(hdc, np)
MoveToEx hdc,x,y,Byval 0
LineTo hdc,x1,y1
BitBlt(hDCmem, 0, 0, ww, hh, hdc, 0, 0, SRCCOPY)
DeleteObject(SelectObject(hdc, op))
ReleaseDC( wID, hdc)
End SUB
SUB Circle (wID as INT, byval cix as INT, byval ciy as INT, byval cra as INT)
hdc = GetDC(wID)
GetSize(wID, 0, 0, ww, hh)
int np = CreatePen(PS_SOLID, 1, fColor)
int op = SelectObject(hdc, np)
Ellipse hdc, cix-cra, ciy-cra, cra+cix, cra+ciy
BitBlt(hDCmem, 0, 0, ww, hh, hdc, 0, 0, SRCCOPY)
DeleteObject(SelectObject(hdc, op))
ReleaseDC( wID, hdc)
End SUB
Sub FillSolidRect(wID as INT, x As Long, Y As Long, cx As Long, cy As Long, bColor as INT)
Dim hBr As Long ' rc As RECT
hDC = GetDC(wID)
rc.Left = x
rc.Top = Y
rc.right = x + cx
rc.bottom = Y + cy
hBr = CreateSolidBrush(bColor)
FillRect hDC, rc, hBr
BitBlt(hDCmem, 0, 0, ww, hh, hdc, 0, 0, SRCCOPY)
DeleteObject(hBr)
ReleaseDC(wID, hdc)
End Sub
SUB CleanUp
DeleteObject(SelectObject(hdcMem, oldBrush))
DeleteObject(SelectObject(hdcMem, oldPen))
DeleteObject(SelectObject(hdcMem, oldBmp))
DeleteDC(hdcMem)
End SUB
Hope this helps.
.