Textbox Problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Textbox Problem

Post by franco »

I have seen this post before but can not locate it.
When in a textbox and when using ONENTER, if I hit the enter button very very fast, program crashes and error message.
Window _Inputbox is not active. Program terminated. The inputbox is my next control in a different window.
I know this was caught with an error but not sure how. I have tried all kinds of things to correct it but I think it is in the keyboard buffer timer.
Any help appreciated ............ Franco ;)
All The Best,
Franco
Canada
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Textbox Problem

Post by Rathinagiri »

Can you provide a small working sample?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Textbox Problem

Post by franco »

I made up a sample but it works ok. I need to do more checking and I will send in error message.
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Textbox Problem

Post by franco »

SUCCESS,
I found an earlier post from Roberto and srvet_claudio.
After the function causing the problem I use hmg_keyboardclearbuffer() which clears the second ENTER HIT.
Should I leave this post for others to see if they have this problem.
Franco ..... ;) .. :lol:
All The Best,
Franco
Canada
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Textbox Problem

Post by Rathinagiri »

Yes. Let it be! :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Textbox Problem

Post by franco »

Ok..They are hard to find sometimes .. ;)
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Textbox Problem

Post by franco »

I am still not happy with the way I resolved the problem.
Does anyone know if there is a way to slow the windows keyboard buffer, or have an error return from my error program that will resume the program. I thought I remember someone had a simular situation of a client pressing keys to fast, and they put in an error like ?to fast then return to program.
clearbuffer works but you must put it where ever someone might hit keys fast.
Thanks Franco ;)
All The Best,
Franco
Canada
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Textbox Problem

Post by mol »

you can catch errors with begin sequence/recover/end sequence.
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Textbox Problem

Post by franco »

This is a example of my problem.
Mol do you know where in the sample I would put your suggestion.

Code: Select all

#include <hmg.ch>

Function Main
PUBLIC MYBOXV:= '', V_QTY := 0, RE := 'F'

        DEFINE WINDOW FORM_1 ;
		AT 0,0 ;
		HEIGHT 360 WIDTH 510 ;
		TITLE ' Enter Speed Test' ;
		MAIN
		
		DEFINE BUTTON BUTTON_1
		ROW 60
		COL 145
		WIDTH 120
		HEIGHT 80
		CAPTION 'Enter Item'
		ACTION { || {ADDTOINVOICE()}}
		END BUTTON
		
		END WINDOW
        FORM_1.Center
        FORM_1.Activate

Return

FUNCTION ADDTOINVOICE
	LOCAL M_ITEM
	MYBOX('Add to Invoice')
	M_ITEM := UPPER(MYBOXV)
	MYBOXV:= ""
	IF RE = 'T'
		RE := 'F'
		RETURN
	ENDIF
	**** This is where crash is if hit enter key twicw very fast in function mybox
	**** This little program does not crash it is not doing much
	V_QTY := VAL(INPUTBOX('Enter Quantity','Quantity', '1'))
	MSGBOX(M_ITEM+'     '+STR(V_QTY))
	
RETURN

FUNCTION MYBOX(Tit)

	            // Private variable myboxv must be set to use as return variable to change
	DEFINE WINDOW Mybox ;
		AT  getDeskTopHeight()/2-50 ,getdesktopWidth() /2-175 ;
		WIDTH 350 ;
		HEIGHT 150 ;
		TITLE TIT ;
		MODAL 
		
		DEFINE LABEL LAB1
         ROW 10
         COL 10
         WIDTH 280
         HEIGHT 20
		 VALUE 'Enter Text    (Escape/Blank to Exit)'
	END LABEL
	
	DEFINE TEXTBOX TEXT1
         ROW 30
         COL 10
         WIDTH 280
         HEIGHT 30
		 ON ENTER { ||  {MYBOXV := MYBOX.TEXT1.VALUE}, {MyBox.Release} }
											// MessageBoxTimeout(,,,500)  //works
	END TEXTBOX
	
		*SetKeys('MYBOX') 
		*ON KEY F1 ACTION Helping('CRSWin.hlp')
		ON KEY ESCAPE OF MyBox Action { || { re := 'T' } ,{MyBox.Release} }	 
		END WINDOW
		
		*MYBOX.TEXT1.VALUE := MYBOXV
		*MYBOX.TEXT1.SETFOCUS
		Mybox.Activate

	Return 
Please see if you see anythng wrong here.
Thanks,.... Franco ;)
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Textbox Problem

Post by serge_girard »

Hi Franco,

This sample works fine.. I can't reproduce no runtime-error while pressing ENTER key.

Serge
There's nothing you can do that can't be done...
Post Reply