Hi! I've been playing around with the example files, and have figured what I need as far as getting something on the screen. I may be missing the completely obvious... but I can't seem to find something to enter numbers with? I mean, something like the "StringGadget" command, but can accept numbers. Basically, I want a box for the user to type a number in, a button for the user to click on (which will perform a simple calculation using the number), then another box which will display the final number after calculation. Any advice will be greatly appreciated
basic help again :)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by willinyork.
Hi! I've been playing around with the example files, and have figured what I need as far as getting something on the screen. I may be missing the completely obvious... but I can't seem to find something to enter numbers with? I mean, something like the "StringGadget" command, but can accept numbers. Basically, I want a box for the user to type a number in, a button for the user to click on (which will perform a simple calculation using the number), then another box which will display the final number after calculation. Any advice will be greatly appreciated
Hi! I've been playing around with the example files, and have figured what I need as far as getting something on the screen. I may be missing the completely obvious... but I can't seem to find something to enter numbers with? I mean, something like the "StringGadget" command, but can accept numbers. Basically, I want a box for the user to type a number in, a button for the user to click on (which will perform a simple calculation using the number), then another box which will display the final number after calculation. Any advice will be greatly appreciated
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Use StringGadgets to input the numbers, then VAL to convert the string to a number. Here is an example...
Of course this example will only add Long numbers.
Edited by - paul on 02 December 2001 16:25:25
Use StringGadgets to input the numbers, then VAL to convert the string to a number. Here is an example...
Code: Select all
InitGadget(4)
#num1 = 1
#num2 = 2
#addbutton = 3
#total = 4
If OpenWindow(0,0,0, 185, 172, #PB_Window_SystemMenu,"Add 2 Numbers")
If CreateGadgetList(WindowID())
StringGadget(#num1,30,10,110,21,"")
StringGadget(#num2,30,40,110,21,"")
ButtonGadget(#addbutton,46,80,80,21,"Add")
StringGadget(#total,30,110,110,21,"")
EndIf
EndIf
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case #addbutton
a.l=Val(GetGadgetText(#num1))
b.l=Val(GetGadgetText(#num2))
SetGadgetText(#total,Str(a+b))
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
Edited by - paul on 02 December 2001 16:25:25
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Kanati.
Kanati
Think he's referring to a masked edit box that only accepts numeric data. Which PB doesn't have as far as I can see. You could probably create your own with keypress events, but that's kind of a kludge.Use StringGadgets to input the numbers, then VAL to convert the string to a number. Here is an example...
Kanati
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by wavemaker.
When PureBasic can't do what you want, use the API, it's also a PB feature:
Bye,
Juan Calderón Alonso
Registered user
When PureBasic can't do what you want, use the API, it's also a PB feature:
Code: Select all
#ES_NUMBER = $2000 ; Constant not present in PB 2.70
InitGadget(4)
#num1 = 1
#num2 = 2
#addbutton = 3
#total = 4
If OpenWindow(0,0,0, 185, 172, #PB_Window_SystemMenu,"Add 2 Numbers")
If CreateGadgetList(WindowID())
number = StringGadget(#num1,30,10,110,21,"")
SetWindowLong_(number, #GWL_STYLE, GetWindowLong_(number, #GWL_STYLE)|#ES_NUMBER)
number = StringGadget(#num2,30,40,110,21,"")
SetWindowLong_(number, #GWL_STYLE, GetWindowLong_(number, #GWL_STYLE)|#ES_NUMBER)
ButtonGadget(#addbutton,46,80,80,21,"Add")
number = StringGadget(#total,30,110,110,21,"")
SetWindowLong_(number, #GWL_STYLE, GetWindowLong_(number, #GWL_STYLE)|#WS_DISABLED)
EndIf
EndIf
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case #addbutton
a.l=Val(GetGadgetText(#num1))
b.l=Val(GetGadgetText(#num2))
SetGadgetText(#total,Str(a+b))
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
Juan Calderón Alonso
Registered user
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Kanati.
Now if someone could just tell me what the heck a '|=' means in a bit of PB code I've run across........
Kanati
Well there you go... More of those undocumented but still there windows constants I wasn't aware of.When PureBasic can't do what you want, use the API, it's also a PB feature:
Juan Calderón Alonso
Registered user
Kanati
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
the Amiga and/or Linux platforms, because they obviously don't have the
API commands and must use the built-in PureBasic commands only. But for
a Windows-only app, then yes, the API is the way to go.
PB - Registered PureBasic Coder
That's assuming that you don't intend to use your PureBasic source onWhen PureBasic can't do what you want, use the API, it's also a PB feature
the Amiga and/or Linux platforms, because they obviously don't have the
API commands and must use the built-in PureBasic commands only. But for
a Windows-only app, then yes, the API is the way to go.
PB - Registered PureBasic Coder
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by wavemaker.
You're absolutely right, PB. I was wrongly assuming that only Windows users were to read these posts, since they don't seem to be very active in their forums. I am an Amiga user, too, and I'd like to port my libraries to Amiga, its Asm is not new to me, but I don't have a PPC, so... BTW, I don't think there's nothing new after Amos and BlitzBasic in Amiga, is it? I don't understand why the Amiga forum in this site is so inactive, I would have been very glad in my Amiga years to have a compiler like this.
Bye,
Juan Calderón Alonso
Registered user
You're absolutely right, PB. I was wrongly assuming that only Windows users were to read these posts, since they don't seem to be very active in their forums. I am an Amiga user, too, and I'd like to port my libraries to Amiga, its Asm is not new to me, but I don't have a PPC, so... BTW, I don't think there's nothing new after Amos and BlitzBasic in Amiga, is it? I don't understand why the Amiga forum in this site is so inactive, I would have been very glad in my Amiga years to have a compiler like this.
Bye,
Juan Calderón Alonso
Registered user
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by plouf.
my mistake then however Purebasic runs ATM only on 68k
ppc suport never completed (dropped??)
and BTW amigaOS API has an integer gadget(numeric)
via gadtool.library (PB also support this via internal libs
but PB lack's other command we waiting for
)
my mistake then however Purebasic runs ATM only on 68k
ppc suport never completed (dropped??)
and BTW amigaOS API has an integer gadget(numeric)
via gadtool.library (PB also support this via internal libs
but PB lack's other command we waiting for