PDA

View Full Version : weird add button error



sandyrepope
30-06-2007, 23:34
I'm getting a strange error with I run the following script. It says in the line that should add a button:

error code 4

error description equal sign expected

line 20

token found hDlg

I'm probably making some kind of simple error but I can't figure out what I'm doing wrong.
Help!!!



uses "UI"
USES "File"

dim hDlg AS long
dim Msg AS LONG
dim wParam AS LONG
dim lParam AS LONG
'---Set starting width and height of the window
dim wx as long = 500
dim hy as long = 300


DIALOG NEW 0, "Month Calendar", -1, -1, wx, hy, _
%WS_DLGFRAME OR %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU OR %WS_OVERLAPPEDWINDOW, _
0 TO hDlg

' ** Display the dialog
DIALOG SHOW modeless hDlg

control add button hDlg, 1101, "", 7, 125, 43, 43

WHILE IsWindow(hDlg)
'---Get the message and fill wParam and lParam
Msg = GetMessage(hDlg, wParam, lParam)


'---Now test the message
SELECT CASE Msg


case %WM_Command

select case wParam
case %ID_EXIT

exit while

end select

CASE %WM_SYSCOMMAND

SELECT CASE wParam
CASE %SC_CLOSE

EXIT WHILE
END SELECT

case else

end select

wend

DIALOG END hDlg

Thanks
Sandy

Petr Schreiber
30-06-2007, 23:39
Hi sandy,

I must go offline now, but your problem should be in fact there must be comma before the hDlg like that:


control add button, hDlg, 1101, "", 7, 125, 43, 43


I think there is a typo in help file.


Bye,
Petr

Michael Clease
01-07-2007, 00:05
its been like that since the day i joined buttons arent the only thing that required the extra comma.

help files need updating or the keyword needs some attention.

sandyrepope
01-07-2007, 03:07
I just tried the little trick with the extra comma and it does indeed work. I have no idea why it works but will continue to use it.

Thanks for both replies. They helped me a lot.
Sandy

ErosOlmi
01-07-2007, 12:53
Yes,

sorry gui. There is a bit of confusion in documentation on that comma. Also a bit of confusion in how the code is parsed from thinBasic engine.
Comma after the class name of the control to be added (BUTTON, LABEL, ...) is mandatory in order to maintain compatibility with Power Basic equivalent syntax.

I will change documentation and optimize parsing code.

Thanks a lot for pointing that.
Eros