Below is 1 of 16 examples I've downloaded that don't work(Very discouraging. Ive got a splash screen and a menu working and I need examples of programs that the menu calls !
;EXAMPLE 1
;Making a window application in PureBasic is easy, just need to understand
;a few easy concepts
;CONSTANTS:
;Constants are used to make readable a code
;Constants are preceded with # and are used to store numeric values so the code will
;be easier to read.
;In this example we create 2 constants to store the ID number that we will
;use for identify the gadgets or controls that we are going to use with our
;application.
#MyStringGadget = 1
#MyButton = 2
;The first step for creating a window in PureBasic is callig the
;OpenWindow() command and sending all the parameters required.
;In this case we give the number 0 as the identifier for our window
;we give the coordinates 100,150 for the left and top position
;of the window
;then give 450 as the Innerwitdh and 200 as innerheight
;The #PB_Window_SystemMenu flag is one of many available (check the help file
;to see the other flags available)
;and then we put the text that will have the window.
***********************************************************
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,Title$,12) < This Line is selected,but I can't find what"s wrong.
************************************************************
;Now we will put the gadgets in the window
CreateGadgetList(WindowID())
StringGadget(#MyStringGadget,50,50,350,20,"")
ButtonGadget(#MyButton,200,100,50,25,"Test")
;and now we will go to a loop to receive any user input
;in this case we will receive when a user pushes a button
Repeat
EventID=WaitWindowEvent();we get the windowevent
Select EventID;we check which window event are we receiving
Case #PB_EventGadget;in case its the event from our gadgets
Select EventGadgetID()
Case #MyButton ; the user click the button
MessageRequester("button clicked","hello world",0)
SetGadgetText(#MyStringGadget,"clicked!!");Then we put a text into the string gadget
EndSelect
EndSelect
Until EventID=#PB_EventCloseWindow;loop until the user decide to close the window
EndIf
End
Why do I get messageLine so & so Bad Parameter Type,expects number ?
Pkease help, I think if I can get just get 1 of these examples to work my Prayers will be answered!!
Error message Bad Parameter, number expected
-
Hot Pockets
- User

- Posts: 51
- Joined: Mon Jun 01, 2009 3:56 am
- Arctic Fox
- Enthusiast

- Posts: 609
- Joined: Sun Dec 21, 2008 5:02 pm
- Location: Aarhus, Denmark
Re: Error message Bad Parameter, number expected
It's just some old syntax for previous versions of PB (before 4.00)
Updated code
Updated code
Code: Select all
;EXAMPLE 1
;Making a window application in PureBasic is easy, just need to understand
;a few easy concepts
;CONSTANTS:
;Constants are used to make readable a code
;Constants are preceded with # and are used to store numeric values so the code will
;be easier to read.
;In this example we create 2 constants to store the ID number that we will
;use for identify the gadgets or controls that we are going to use with our
;application.
#MyStringGadget = 1
#MyButton = 2
;The first step for creating a window in PureBasic is callig the
;OpenWindow() command and sending all the parameters required.
;In this case we give the number 0 as the identifier for our window
;we give the coordinates 100,150 for the left and top position
;of the window
;then give 450 as the Innerwitdh and 200 as innerheight
;The #PB_Window_SystemMenu flag is one of many available (check the help file
;to see the other flags available)
;and then we put the text that will have the window.
; ***********************************************************
If OpenWindow(0,100,150,450,200,Title$,#PB_Window_SystemMenu,12); < This Line is selected,but I can't find what"s wrong.
; ************************************************************
;Now we will put the gadgets in the window
StringGadget(#MyStringGadget,50,50,350,20,"")
ButtonGadget(#MyButton,200,100,50,25,"Test")
;and now we will go to a loop to receive any user input
;in this case we will receive when a user pushes a button
Repeat
EventID=WaitWindowEvent();we get the windowevent
Select EventID;we check which window event are we receiving
Case #PB_Event_Gadget;in case its the event from our gadgets
Select EventGadget()
Case #MyButton ; the user click the button
MessageRequester("button clicked","hello world",0)
SetGadgetText(#MyStringGadget,"clicked!!");Then we put a text into the string gadget
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow;loop until the user decide to close the window
EndIf
End
Re: Error message Bad Parameter, number expected
Hi,
simply go on the command which produce the fault (with the cursor) and press F1.
In the upcoming help you can read something like that:
Ergebnis = OpenWindow(#Window, x, y, InnereBreite, InnereHoehe, Titel$ [, Flags [, ParentWindowID]])
So you can see, that your parameters are wrong sorted.
(even when my help is from the german help-file)
Best regards,
Bernd
Oh, to late, only second

simply go on the command which produce the fault (with the cursor) and press F1.
In the upcoming help you can read something like that:
Ergebnis = OpenWindow(#Window, x, y, InnereBreite, InnereHoehe, Titel$ [, Flags [, ParentWindowID]])
So you can see, that your parameters are wrong sorted.
(even when my help is from the german help-file)
Best regards,
Bernd
Oh, to late, only second
Re: Error message Bad Parameter, number expected
Code: Select all
OpenWindow(0,100,150,450,200,Title$, #PB_Window_SystemMenu,12)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
-
Hot Pockets
- User

- Posts: 51
- Joined: Mon Jun 01, 2009 3:56 am
Re: Error message Bad Parameter, number expected
Mr SFSs01
Sorry the number 12 was put in to replace the "" that was there originally. The message said that a number was expected so I replaced "" with 12. That did NOT solve the problem. I downloaded these from Purearea and none of the 8 examples work &
they all get the same message.Why?
Sorry the number 12 was put in to replace the "" that was there originally. The message said that a number was expected so I replaced "" with 12. That did NOT solve the problem. I downloaded these from Purearea and none of the 8 examples work &
they all get the same message.Why?
Re: Error message Bad Parameter, number expected
replace
with
the code you are using is for an old version of PB, the parameter order of the OpenWindow function has changed - the window title string and the flag have swapped places; so where PB is expecting to find a string, it is finding a number, and vice-versa
when in doubt, have a look at the manual, it's really helpful in cases like this
Code: Select all
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,Title$,12)Code: Select all
If OpenWindow(0, 100, 150, 450, 200, Title$ , #PB_Window_SystemMenu)when in doubt, have a look at the manual, it's really helpful in cases like this
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat

