Code from PureArea

Just starting out? Need help? Post your questions and find answers here.
RNBW
User
User
Posts: 76
Joined: Thu Jan 02, 2014 5:01 pm

Code from PureArea

Post by RNBW »

I tried to run the following code for "NumbersInStringGadget.pb" from PureArea (Translated to English, but the same happens in German). It comes up with the error "Line 29: number_Click is not a valid operator'.

Code: Select all

; German forum: Translated to English
; Author: OzBernd (updated for PB4.00 by blbltheworm)
; Date: 20. December 2002
; OS: Windows
; Demo: No


; Number String Gadget 
; Feel free to use it anywhere, anytime 
; Pay attention to decimal and thousandth characters 
;------------------------------------------------ 

Form1_hWnd= OpenWindow(0,100,200,200,200,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
;If Form1_hWnd=0 Or CreateGadgetList(Form1_hWnd)=0 : End : EndIf 
If Form1_hWnd=0  : End : EndIf

#number = 1 
#label = 2 
string_hWnd= StringGadget(#number,10,50,100,20,"") 
label_hWnd = TextGadget(#label, 10,30,100,20,"Enter limit") 
GadgetToolTip(#number,"Please enter your desired credit limit") 
SetActiveGadget(#number) 

Repeat 
  EventID=WaitWindowEvent() 
  Select EventID 
    Case #PB_Event_Gadget 
      Select EventGadget() 
        Case #number :FakeEndSelect: Gosub number_Click 
        
    EndSelect 
  EndSelect 
  esc=GetAsyncKeyState_(#VK_ESCAPE) 
  ret=GetAsyncKeyState_(#VK_RETURN) 
Until EventID=#PB_Event_CloseWindow Or esc=-32767 Or ret=-32767 


;Swap format according to German convention
text$ = ReplaceString(text$, ",", ".",1,1) 
          
Debug text$ 




      
End    
          
; Process input, exclude NoNumbers and place cursor at the end 
number_Click: 

text$ = GetGadgetText(#number) 
If Len(text$)> 0 
   input.b = Asc(RTrim(Right(text$,1))) 
   If input >=44 And input <=57 And input <> 47      ; numbers 0 to 9, -., 
      Return 
   Else 
     SetGadgetText(#number,Left(text$,Len(text$)-1))          ;delete last character
     SendMessage_(string_hWnd,#EM_SETSEL, Len(text$),-1)  ;Place cursor at the end 
   EndIf 
EndIf 

Return 
End 

; IDE Options = PureBasic v4.00 (Windows - x86)
; Folding = -
; EnableXP
I don't understand.
normeus
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Code from PureArea

Post by normeus »

replace this line:

Code: Select all

Case #number :FakeEndSelect: Gosub number_Click 

with this:

Code: Select all

        Case #number
          Gosub number_Click
I did not check the whole program. looks like It was created for PB 4.00. With older programs, you have to check for language changes.
There are probably other examples doing the same thng in this forum, that use newer versions of PB

Norm
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
RNBW
User
User
Posts: 76
Joined: Thu Jan 02, 2014 5:01 pm

Re: Code from PureArea

Post by RNBW »

Thank you for your very prompt reply.
I've been away from programming for a little while and I'm trying to catch up again. Your suggestion got rid of the error.
Thank you.
User avatar
jacdelad
Addict
Addict
Posts: 2027
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Code from PureArea

Post by jacdelad »

Umm...this should be rewritten to use a procedure instead of gosub.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
mk-soft
Always Here
Always Here
Posts: 6285
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Code from PureArea

Post by mk-soft »

Some codes on the PureArea are also getting old and need to be revised a lot.
Many already have alternative codes here in the forum.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
AZJIO
Addict
Addict
Posts: 2211
Joined: Sun May 14, 2017 1:48 am

Re: Code from PureArea

Post by AZJIO »

Why don't you use the new sources? You can go back to the old ones when you can't find anything in the new ones.
viewtopic.php?p=492472#p492472
viewtopic.php?p=590228#p590228
RNBW
User
User
Posts: 76
Joined: Thu Jan 02, 2014 5:01 pm

Re: Code from PureArea

Post by RNBW »

jacdelad wrote: Sun Oct 12, 2025 7:14 am Umm...this should be rewritten to use a procedure instead of gosub.
I think you are correct. I'll give it a go.

The idea and its code could be useful to incorporate in a program if you need alternative output of numbers where countries don't use a comma as a decimal point and use a full stop as the decimal point.
RNBW
User
User
Posts: 76
Joined: Thu Jan 02, 2014 5:01 pm

Re: Code from PureArea

Post by RNBW »

AZJIO wrote: Sun Oct 12, 2025 8:48 am Why don't you use the new sources? You can go back to the old ones when you can't find anything in the new ones.
viewtopic.php?p=492472#p492472
viewtopic.php?p=590228#p590228
Thank you for the links, they are very useful.
AZJIO
Addict
Addict
Posts: 2211
Joined: Sun May 14, 2017 1:48 am

Re: Code from PureArea

Post by AZJIO »

RNBW wrote: Sun Oct 12, 2025 11:44 am Thank you for the links, they are very useful.
There's a newer one here
viewtopic.php?t=62741
viewtopic.php?t=80656
Post Reply