Textbox Problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Textbox Problem

Post by franco » Tue May 30, 2017 10:38 pm

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 ;)

User avatar
Rathinagiri
Posts: 5162
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 128 times
Been thanked: 130 times
Contact:

Post by Rathinagiri » Wed May 31, 2017 4:11 am

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: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed May 31, 2017 2:57 pm

I made up a sample but it works ok. I need to do more checking and I will send in error message.

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed May 31, 2017 4:52 pm

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:

User avatar
Rathinagiri
Posts: 5162
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 128 times
Been thanked: 130 times
Contact:

Post by Rathinagiri » Wed May 31, 2017 4:58 pm

Yes. Let it be! :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Wed May 31, 2017 8:18 pm

Ok..They are hard to find sometimes .. ;)

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Thu Jun 01, 2017 5:18 am

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 ;)

User avatar
mol
Posts: 2841
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 118 times
Been thanked: 64 times
Contact:

Post by mol » Fri Jun 02, 2017 5:22 am

you can catch errors with begin sequence/recover/end sequence.

franco
Posts: 200
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 6 times

Post by franco » Sat Jun 03, 2017 5:17 pm

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 ;)

User avatar
serge_girard
Posts: 1838
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 278 times
Been thanked: 63 times
Contact:

Post by serge_girard » Mon Jun 05, 2017 8:21 am

Hi Franco,

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

Serge

Post Reply