Page 1 of 1

Memory variables and alternate syntax

Posted: Sun Nov 15, 2009 6:41 pm
by karweru
Hi Friends,

I'm trying the following code and is returning syntax errors when compiled.

#include "minigui.ch"

FUNCTION main()
local cWindow:="win_1"
local nRow:=0
local nCol:=0
local nWidth:=400
local nHeight:=200
local cTitle:="Hello world"
local cWinType:="MAIN"

DEFINE WINDOW &cWindow
ROW &nRow
COL &nCol
WIDTH &nWidth
HEIGHT &nHeight
TITLE &cTitle
WINDOWTYPE &cWinType
END WINDOW

ACTIVATE WINDOW &cWindow
Return


Is there any way around this?

Thanks in advance.

Re: Memory variables and alternate syntax

Posted: Sun Nov 15, 2009 7:41 pm
by Roberto Lopez
karweru wrote:Hi Friends,

I'm trying the following code and is returning syntax errors when compiled.

#include "minigui.ch"

FUNCTION main()
local cWindow:="win_1"
local nRow:=0
local nCol:=0
local nWidth:=400
local nHeight:=200
local cTitle:="Hello world"
local cWinType:="MAIN"

DEFINE WINDOW &cWindow
ROW &nRow
COL &nCol
WIDTH &nWidth
HEIGHT &nHeight
TITLE &cTitle
WINDOWTYPE &cWinType
END WINDOW

ACTIVATE WINDOW &cWindow
Return


Is there any way around this?

Thanks in advance.
WIndow type is 'hard-coded' in the command definition, but for all other thing you can use variables (there is no need for macro).

Re: Memory variables and alternate syntax

Posted: Sun Nov 15, 2009 8:57 pm
by Alex Gustow
Hi Karweru!

And (in additional to Roberto's advice) - you must have MAIN window into your program (if you need any window(s) - except MsgInfo(), MsgStop()... etc.) (correct me, friends, if I'm wrong).

So add "MAIN" into DEFINE WINDOW (if this window really must be "main") and (if you want to define window's parameters programmatically) write something like this (again: if I'm wrong - correct me, friends):

Code: Select all

function Main()

  local nRow, nCol, nWidth, nHeight

  nRow:=0
  nCol:=0
  nWidth:=600
  nHeight:=400
 
  Fun_1( nRow, nCol, nWidth, nHeight )

Return Nil

//---------
function Fun_1 ( nRow0, nCol0, nWidth0, nHeight0 )

  define window Win_1 ;
    at nRow0, nCol0 ;
    width nWidth0 ;
    height nHeight0 ;
    MAIN ;
    on init { || Fun_2(), Win_1.Release }

    // ... here - other controls definition (if needed just here)

  end window

  Win_1.Center
  Win_1.Activate

Return Nil

//---------
function Fun_2 ( )

  // ...when main window activates - other work will starts from here...
  // for example: you'll can define other conrols of this window here -
  // depending on _actual_ sizes of window
  // (you already know them at this moment!)

Return Nil
I think - it must work.

Re: Memory variables and alternate syntax

Posted: Mon Nov 16, 2009 10:36 am
by karweru
Thanks so much Roberto for the info. Alex, thanks too. I appreciate the details. Actually I started the experiment after stumbling onto ooHg, which is basically an object oriented minigui offshoot. I was of the opinion it is possible to create classes for the various controls around the alternate syntax, without calling _define* functions directly and without needing to use any other tool other than hmg.
As it now, anybody wanting to program in an oop way, would have to call _define* functions directly due to the 'hard coding' of some arguments.

All the same, thanks.

Warm regards.

Re: Memory variables and alternate syntax

Posted: Mon Nov 16, 2009 11:03 am
by Alex Gustow
Hi Karweru!
Try HWGUI too - it's OOP-library (MiniGUI is "Semi-OOP", as Roberto wrote).
Look at wiki about it - http://hwgui.altervista.org/doku.php

Re: Memory variables and alternate syntax

Posted: Tue Nov 17, 2009 5:43 am
by karweru
Hi Alex,

Thanks for the info but i'm in Hmg - for life! Hmg does not in any impede use of oop if one wanted to despite its' semi-oop implementation, which is also brilliant. I have actually been using it for more than an year but by calling _define* funtions directly. Maybe one day the master might enable calling the alternate syntax fully without the 'hard codings', but i believe this is not critical.

Thanks and cheers.

Re: Memory variables and alternate syntax

Posted: Tue Nov 17, 2009 7:05 am
by Alex Gustow
Hi Karweru,
I use HMG only too! I tried to use HWGUI in the beginning of my "Harbour life" :) - 2 or 3 years ago - and found that MiniGUI is much better, friendly etc. But many people (in "comp.lang.xharbour" newsgroup and in other places) has different opinion (they want "full OOP" - but I'm not need it).