Page 1 of 1

Alternate Syntax

Posted: Tue Jul 27, 2010 8:35 am
by karweru
Hello friends,

Please help me understand this;

In alternate syntax, you can do the following;

Code: Select all

Define Window <windowName>
Row <nRow>
Col <nCol>
Width <nWidth>
Height <nHeight>
WindowType MAIN | CHILD | MODAL | SPLITCHILD | STANDARD | PANEL 
.....
The values in <> can be supplied from memory variables viz;

Code: Select all

Define Window &WindowName Row nRow Col nCol Width nWidth Height nHeight WindowType MAIN
End Window
Is there a reason why;

1. WindowType cannot be passed in a memory variable
2. why there must be a macro symbol before windowName?
3. Why the define statement cannot be broken into more than one line

Please forgive my curiosity. I would really appreciate any insights.

Re: Alternate Syntax

Posted: Tue Jul 27, 2010 9:07 am
by Rathinagiri
Nice questions Gilbert.

Let me answer to the level possible.

1. Because, window type is already predefined one. Like "define window". We can't change the compiler preprocessor directives.

However we can do the following:

Code: Select all

cWindowType := "MAIN"
do case
   case cWindowType == "MAIN"
      define window..... MAIN
   case cWindowType == "CHILD"
      define window ..... CHILD
endcase
end window
2. Because, if we don't include the macro symbol, the variable name would be the windowname!

For example,

Suppose we have,

Code: Select all

cName := "WindowName"
"define window cName" would define a window in the name of cName, where thiswindow.name = 'cName'
"define window &cName" would define a window in the name of WindowName where thiswindow.name = 'WindowName'

Therefore, using macro symbol depends upon our requirement.

3. If we go through all the header files (c:\hmg\include\i_tree.ch,i_tab.ch,i_window.ch) defining the statements (from alternate syntax) which can't be broken (like window, tab, tree etc.,) we can understand the following:

Window, tree and tab controls are controls containing other controls. Prior to entering the control details (ie., before end tree/end tab/end window) we must give the proper name, width, height, row, col and other properties in the define statement itself. Once we give the define statement, a corresponding function is executed to define these containers and the "end window", "end tree" and "end tab" statements will be just closing the definitions.

Where as, for all other controls (say textbox, editbox, button, slider, grid etc.,) once we give "define textbox" statement, no function is called for. It is only fixing the default values for all the properties. At the time of giving the "end textbox" statement, a function with all these parameters is called.

So, the difference is, the time of calling the function defining the control/container. If we define the container before "end window/tree/tab" we can't break the line. If we define the control after "end textbox/editbox/button..." we can break the line.

We must thank Roberto for designing this excellent syntax via compiler preprocessor directives. :idea:

Re: Alternate Syntax

Posted: Tue Jul 27, 2010 9:13 am
by Rathinagiri
If we have to compulsorily break the line, then we should have something like this. For this Roberto's help is required.

Code: Select all

define window FormName
   start definitions
      row 0
      col 10
      width 800
      height 600
      windowtype main
      title "This is the title"
   end definitions
   define button ok
      row 10
      col 10
      width 100
      caption "Ok"
      action msginfo("Ok Button is pressed")
   end button
end window
formname.activate() 

Re: Alternate Syntax

Posted: Tue Jul 27, 2010 12:04 pm
by esgici
Perfect explanation, Thanks Rathi :)

Regards

--

Esgici

Re: Alternate Syntax

Posted: Tue Jul 27, 2010 2:10 pm
by karweru
Thanks Rathi, excellent explanation. I understand a little better now. I wish one day Roberto might find a way round.....