XBROWSE: clausola SELECT per filtrare solo alcuni record

Moderator: Enrico Maria Giordano

XBROWSE: clausola SELECT per filtrare solo alcuni record

Postby max » Mon Sep 22, 2008 1:34 pm

Dovrei filtrare su un XBROWSE solo alcuni record, lavorando sul contenuto del campo chiave.
Ho visto che si può fare utilizzando la SELECT, ma non riesco a farla funzionare come dovrebbe. Questo è il mio codice:

Code: Select all  Expand view
local oBRW,oDLG
use clienti
index on importo to custntx
DEFINE DIALOG oDLG RESOURCE "PROVA"
redefine XBROWSE oBRW ID 101 of oDLG FIELDS clienti->ragsoc,clienti->importo ;
      SELECT IMPORTO FOR IMPORTO=1000 TO IMPORTO=1000 ;
      FIELDSIZES 150,150 ;
      HEADERS "RAGIONE SOCIALE","IMPORTO"
ACTIVATE DIALOG oDLG CENTERED


Messo così (e in altre forme leggermente diverse che ho provato), l'xbrowse sempre e comunque butta fuori tutti i record e non solo quelli con importo=1000 che è invece quel che vorrei.
Non sono riuscito a trovare esempi in merito in \fwh\samples: qualcuno può darmi una dritta in merito?
grazie.


FWH 8.04 - XHARBOUR 1.1.0
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy


Postby max » Mon Sep 22, 2008 2:27 pm

Nulla da fare: ho provato e ri-provato anche così ed è come se non lo sentisse proprio...
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Postby max » Mon Sep 22, 2008 2:39 pm

Ho ricontrollato anche il file indice, ho provato a creare l'indice su un campo Character anziché numerico... ma niente, non riesco proprio a farla funzionare.
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Postby Enrico Maria Giordano » Mon Sep 22, 2008 4:21 pm

Prova con un TWBrowse. Se con quello funziona e con l'XBrowse no allora è certamente un problema in quest'ultimo.

Comunque per me la soluzione migliore è utilizzare la funzione OrdScope().
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby max » Mon Sep 22, 2008 4:44 pm

ordscope() ??
Non la trovo nella documentazione né nei samples: puoi darmi qualche input che poi provo anch'io?
grazie.
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Postby Enrico Maria Giordano » Mon Sep 22, 2008 4:51 pm

Come fai a non trovarla? E' una funzione standard del Clipper. Dalle Norton Guides:

ORDSCOPE()
Set or clear the boundaries for scoping key values in the controlling order

Syntax

ORDSCOPE(<nScope>, [<expNewValue>]) --> uCurrentValue

Arguments

<nScope> is a number specifying the top (TOPSCOPE) or bottom
(BOTTOMSCOPE) boundary.

Note: To use the TOPSCOPE and BOTTOMSCOPE constants, you must
include (#include) the Ord.ch header file in your application.

<expNewValue> is the top or bottom range of key values that will be
included in the controlling order's current scope. <expNewValue> can be
an expression that matches the data type of the key expression in the
controlling order or a code block that returns the correct data type.

Omitting <expNewValue> or specifying it as NIL has the special effect of
resetting the specified scope to its original default. The default top
range is the first logical record in the controlling order, and the
default bottom range is the last logical record.

Returns

If <expNewValue> is not specified, ORDSCOPE() returns and clears the
current setting. If <expNewValue> is specified, the function sets it
and the previous setting is returned.

Description

The range of values specified using ORDSCOPE() is inclusive. In other
words, the keys included in the scope will be greater than or equal to
the top boundary and less than or equal to the bottom boundary.

Note: To return current settings without changing them, call the
DBORDERINFO() function using the DBOI_SCOPETOP and DBOI_SCOPEBOTTOM
constants.

Examples

þ This example illustrates using ORDSCOPE() to set various
scoping limitations on an order:

USE Friends
SET INDEX TO Age

// Make 25 the lowest age in range
ORDSCOPE(TOPSCOPE, 25)

// Make 30 the highest age in range
ORDSCOPE(BOTTOMSCOPE, 30)
LIST Age // Shows records with
// 25 <= Age <= 30

// Change highest age to 35
ORDSCOPE(BOTTOMSCOPE, 35)
LIST Age // Shows records with
// 25 <= Age <= 35

// Reset top boundary
ORDSCOPE(TOPSCOPE, NIL)
LIST Age // Shows records with
// Age <= 35


// Reset bottom boundary
ORDSCOPE(BOTTOMSCOPE, NIL)
LIST Age // Shows all records

Files Library is CLIPPER.LIB, header file is Ord.ch.


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby max » Mon Sep 22, 2008 5:11 pm

Confesso di non averla mai usata né conosciuta.
(Prima di scriverti poi sono pure andato a cercarla nella mia guida NG di clipper e delle clippertools e non l'ho trovata. Forse ne ho una più vecchia, boh...!)

Comunque se questa va e non ha gli intoppi del SET FILTER nei dbf con molti record allora la uso anch'io di sicuro.
grazie.
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy


Return to All products support

Who is online

Users browsing this forum: No registered users and 10 guests