Lookup Table

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Tristan
Posts: 40
Joined: Sun Jul 19, 2009 2:15 pm

Lookup Table

Post by Tristan »

Hi All,

How to make lookup table, example if key F2 or klik button can display list of customer and when enter, cust id can display ?

In Clipper, I use SuperLib Library Function.

Best Regards,
Tristan
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: Lookup Table

Post by Rathinagiri »

I think Sudip would be the right person to answer.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Lookup Table

Post by esgici »

Hi Tristan
Tristan wrote:Hi All,

How to make lookup table, example if key F2 or klik button can display list of customer and when enter, cust id can display ?

In Clipper, I use SuperLib Library Function.

Best Regards,
Tristan
What is name of function you use from Superlib ?

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Lookup Table

Post by sudip »

Hello Tristan,

I am only a learner of HMG :)
Some times ago I wrote a function which may solve your problem:
findform.jpg
findform.jpg (27.12 KiB) Viewed 6371 times
Following code may have bugs, but hope will help :)
wAcct.zip
(2.08 KiB) Downloaded 478 times
Please check FindRec() function :)
With best regards.
Sudip
With best regards,
Sudip
Tristan
Posts: 40
Joined: Sun Jul 19, 2009 2:15 pm

Re: Lookup Table

Post by Tristan »

Hi Mr. Esgici,
I use smallkset and smalls function for lookup table.

Hi Mr. Sudip,
Thanks for example, but I get error when compile.

Thanks,
Tristan
Attachments
wAcct.JPG
wAcct.JPG (35.82 KiB) Viewed 6327 times
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Lookup Table

Post by sudip »

Hello Tristan,

I didn't send the total source code. I only showed you how to do this :)

Please check following code snippet :

Code: Select all

Function FindRec()
	local mRecno, aAcctnm := {}, i :=0
	netselect("ACCT")
	set order to 2
	mRecno = iif(eof(), 0, recno())
	go top
	dbeval({|| aadd(aAcctnm, acct->acctnm)})
	
	if recno() <> 0
		go (mRecno)
	endif
	
	i := frmFind(aAcctnm)
	
	if i > 0
		netselect("acct")
		set order to tag acctnm
		seek upper(aAcctNm[i])
		RefreshData()
	endif
	
	return nil
	

Function FrmFind(aData)
private aTempData := {}, mPtr := 0

	aeval(aData, {|x| aadd(aTempData, x)})
	
	WinFrmFind()
	frmFind.Center
	frmFind.Activate
	Return (mPtr)


Static function InitFind()
	frmFind.lstFind.deleteallitems()
	aeval(aTempData, {|x| frmFind.lstFind.additem(x)})
	frmFind.lstFind.setfocus()
	return nil
			
	
	
Function WinfrmFind()	
	
DEFINE WINDOW AT 140 , 235 ;
	WIDTH 550 HEIGHT 394 ;
	TITLE "Find"
	MODAL ;
	ON INIT InitFind()

    DEFINE BUTTON cmdOk
           ROW    330
           COL    120
           WIDTH  100
           HEIGHT 28
           ACTION {mPtr := frmFind.lstFind.value, frmFind.release()}
           CAPTION "&Ok"
     END BUTTON  

    DEFINE BUTTON cmdCancel
           ROW    330
           COL    300
           WIDTH  100
           HEIGHT 28
           ACTION {mPtr = 0, frmFind.release()}
           CAPTION "&Cancel"
     END BUTTON  

     DEFINE LISTBOX lstFind
            ROW    0
            COL    0
            WIDTH  541
            HEIGHT 323
            ITEMS {""}
            VALUE 0
            FONTNAME "Lucida Console"
            FONTSIZE 10
            BACKCOLOR {253,254,199}
            ONDBLCLICK {frmFind.cmdOk.action()}
     END LISTBOX  

END WINDOW	
return nil
With best regards.

Sudip
With best regards,
Sudip
Tristan
Posts: 40
Joined: Sun Jul 19, 2009 2:15 pm

Re: Lookup Table

Post by Tristan »

Hi Mr. Sudip,

Why use array not use direct table ? If use array all data should transfer to array, it takes time.

Regards,
Tristan
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Lookup Table

Post by sudip »

Tristan wrote: Why use array not use direct table ? If use array all data should transfer to array, it takes time.
Because,
1) I want to make the code generic (please check FrmFind() function onwords). This code can be used with any table :)
2) This code can be used with SQL tables also where we store data into array :)
3) Generally Lookup table (in old days we called Master table) is not so big comparing Transaction table :)
4) I am a great admirer of GRID :) Please check VIRTUAL property of GRID in the Reference regarding performance :)

But, I can't say that I am always correct, as I am learning HMG ;)

So, please send your comments regarding this :)

With best regards.

Sudip
With best regards,
Sudip
Tristan
Posts: 40
Joined: Sun Jul 19, 2009 2:15 pm

Re: Lookup Table

Post by Tristan »

Hi Mr. Sudip :P ,

In array only support 4800 line, is it right ? What happen if table have more than 4800 record ?

Thanks for advance.

Regards,
Tristan
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Lookup Table

Post by sudip »

Tristan wrote: In array only support 4800 line, is it right ? What happen if table have more than 4800 record ?
I just tested to store some fields into an array of a table having 429712 records. It runs fine. So this array has 429712 rows and 3 columns :o

Code: Select all

...
...	
Function TestRecord()
	local i := 0, mTotRec
	aData := {}
	select saledtl
	mTotRec := reccount()
	go top
	main.progressbar_1.value := 0
	do while !eof()
		do events
		i++
		main.label_1.value := ltrim(str(i))+" / "+ltrim(str(mTotRec))
		main.progressbar_1.value := i/mTotRec*100
		aadd(adata, {saleid, styleid, sizeid})
		skip
	enddo
	msgbox("complete")
	go top
	return nil
Harbour is very powerful :D
With best regards.
Sudip
Last edited by sudip on Tue Nov 10, 2009 9:02 am, edited 2 times in total.
With best regards,
Sudip
Post Reply