Page 1 of 1
build "Filter" for Array
Posted: Mon Aug 17, 2020 8:37 pm
by AUGE_OHR
hi,
when have a Array i don“t have "Name" of Column only "Number".
when build a "Filter" it look like this
now i want that User "on-fly" can build a "Filter" with Mouse and ComboBox
i got it with FIELD Name and DBF but how with Array and Column "Number"
---
i have read about "virtual DBF" but not sure how to use it instead of Array.
DIRECTORY() return Array ... how to transfer Array into "virtual DBF"

Re: build "Filter" for Array
Posted: Tue Aug 18, 2020 5:43 am
by mol
If I understand well, you should declare second array conaining headers only.
If you want to use memory tables, watch samples\advanced\memory_tables\demo.prg
Code: Select all
/*
* HMG - Harbour Win32 GUI library Demo
*
* Copyright 2002-2010 Roberto Lopez <mail.box.hmg@gmail.com>
* http://www.hmgforum.com//
*
* Copyright 2009 Grigory Filatov <gfilatov@freemail.ru>
*
* Based on MEMIO sample included in Harbour distribution
*/
#include "hmg.ch"
REQUEST HB_MEMIO
*--------------------------------------------------------*
Function Main()
*--------------------------------------------------------*
OpenTable()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'Memory File System Demo' ;
MAIN NOMAXIMIZE
DEFINE MAIN MENU
DEFINE POPUP 'Test'
ITEM "Exit" ACTION ThisWindow.Release()
END POPUP
END MENU
@ 10,10 GRID grid_1 ;
WIDTH 610 ;
HEIGHT 390 ;
HEADERS { 'Code' , 'Name' , 'Residents' } ;
WIDTHS { 50 , 160 , 100 } ;
ROWSOURCE "memarea" ;
COLUMNFIELDS { 'Code' , 'Name' , 'Residents' } ;
JUSTIFY { GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_RIGHT }
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return nil
*--------------------------------------------------------*
Procedure OpenTable
*--------------------------------------------------------*
CreateTable()
INDEX ON FIELD->RESIDENTS TAG residents
GO TOP
Return
*--------------------------------------------------------*
Procedure CloseTable
*--------------------------------------------------------*
DBCLOSEAREA()
DBDROP("mem:test") // Free memory resource
Return
*--------------------------------------------------------*
Function CreateTable
*--------------------------------------------------------*
DBCREATE("mem:test", {{"CODE", "C", 3, 0},{"NAME", "C", 50, 0},{"RESIDENTS", "N", 11, 0}},, .T., "memarea")
DBAPPEND()
REPLACE CODE WITH 'LTU', NAME WITH 'Lithuania', RESIDENTS WITH 3369600
DBAPPEND()
REPLACE CODE WITH 'USA', NAME WITH 'United States of America', RESIDENTS WITH 305397000
DBAPPEND()
REPLACE CODE WITH 'POR', NAME WITH 'Portugal', RESIDENTS WITH 10617600
DBAPPEND()
REPLACE CODE WITH 'POL', NAME WITH 'Poland', RESIDENTS WITH 38115967
DBAPPEND()
REPLACE CODE WITH 'AUS', NAME WITH 'Australia', RESIDENTS WITH 21446187
DBAPPEND()
REPLACE CODE WITH 'FRA', NAME WITH 'France', RESIDENTS WITH 64473140
DBAPPEND()
REPLACE CODE WITH 'RUS', NAME WITH 'Russia', RESIDENTS WITH 141900000
Return Nil
Re: build "Filter" for Array
Posted: Tue Aug 18, 2020 4:27 pm
by franco
If you have a large table you can use Mol`s idea but use a for in the index.
INDEX ON FIELD->RESIDENTS TAG residents FOR residents > 3000000.
I am not sure if FOR goes before tag or after tag, I have never used tags.
What I use is the original table and use a temporary index.
I create a c:\HMGTEMP folder at the start of every main program, This way if using work stations I create temp index in local computer (FASTER)
Memory table are even faster but I feel the more memory I use can slow computer, Not sure.
Then I
USE ORGINAL SHARED
INDEX ON NAME FOR RESIDENTS > 3000000 TO C:\HMGTEMP\TEMP
GO TOP
CODE >>>>>>>>>> GRID USES TABLE FIELDS INSTEAD OF ARRAY
CLOSE ORIGINAL
TEMP := "C:\HMGTEMP\TEMP.NTX"
ERASE (TEMP)
RETURN
Now you have your filter.