Página 1 de 1

DbSetOrder ou OrdSetFocus() ?

Enviado: 03 Jan 2010 10:48
por clodoaldomonteiro
Hoje quando estava atualizando meus fontes de clipper para xHarbour, percebi que existia essas duas funções, que teoricamente fazem a mesma coisa, mas qual delas deveria usar, para que o sistema fique com uma melhor performance?

Vi também que no Clipper devo passar uma string para a função OrdSetFocus() e no xHarbour pede um inteiro.

Vejam o comentário no xHarbour:
OrdSetFocus()
Sets focus to the controlling index in a work area
Syntax
OrdSetFocus( [<nOrder>|<cIndexName>], ;
[<cIndexFile>] ) --> cOldIndexName

Arguments
<nOrder>
A numeric value specifying the ordinal position of the index open in a work area to select as the controling index. Indexes are numbered in the sequence of opening, beginning with 1. The value zero identifies the controlling index.
<cIndexName>
Alternatively, a character string holding the symbolic name of the index to select can be passed. It is analogous to the alias name of a work area. Support for <cIndexName> depends on the RDD used to open the index. Usually, RDDs that are able to maintain multiple indexes in one index file support symbolic index names, such as DBFCDX, for example.
<cIndexFile>
<cIndexFile> is a character string with the name of the file that stores the index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>.
No clipper:
ORDSETFOCUS()
Set focus to an order in an order list

Syntax

ORDSETFOCUS([<cOrderName> | <nOrder>]
[,<cOrderBagName>]) --> cPrevOrderNameInFocus

Arguments

<cOrderName> is the name of the selected order, a logical ordering
of a database. ORDSETFOCUS() ignores any invalid values of
<cOrderName>.

<nOrder> is a number representing the position in the order list of
the selected order.

<cOrderBagName> is the name of a disk file containing one or more
orders. You may specify <cOrderBagName> as the file name with or
without the path name or appropriate extension. If you do not include
the extension as part of <cOrderBagName>, CA-Clipper uses the default
extension of the current RDD.

Returns

ORDSETFOCUS() returns the order name of the previous controlling order.
Essas não deverian ser a mesma função?

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 03 Jan 2010 11:17
por alaminojunior
Eu usava no Clipper e continuo usando ordsetfocus() no xHarbour.
A sintaxe é a mesma:

Código: Selecionar todos

OrdSetFocus("indice")


Onde "indice" é uma string que contém o nome do índice dentro da bolsa de ordens, por exemplo:

Código: Selecionar todos

index on nome tag indice to indcdx
index on fone tag tele to indcdx
Sobre performance, não saberia dizer se existe algum ganho ou perda.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 03 Jan 2010 12:37
por alxsts
Olá!

Talvez este tópico te forneça alguma informação adicional.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 04 Jan 2010 10:49
por jamazevedo
Sempre utilizei e utilizo o DBSETORDER e nunca tive problemas.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 04 Jan 2010 15:56
por clodoaldomonteiro
Mas Alamino...

Antes no clipper o OrdSetFocus() pedia uma string e essa função no Harbour pede um inteiro.

No Harbour:


OrdSetFocus()
Sets focus to the controlling index in a work area
Syntax
OrdSetFocus( [<nOrder>|<cIndexName>], ;
[<cIndexFile>] ) --> cOldIndexName

Arguments
<nOrder>
A numeric value specifying the ordinal position of the index open in a work area to select as the controling index. Indexes are numbered in the sequence of opening, beginning with 1. The value zero identifies the controlling index.
<cIndexName>
Alternatively, a character string holding the symbolic name of the index to select can be passed. It is analogous to the alias name of a work area. Support for <cIndexName> depends on the RDD used to open the index. Usually, RDDs that are able to maintain multiple indexes in one index file support symbolic index names, such as DBFCDX, for example.
<cIndexFile>
<cIndexFile> is a character string with the name of the file that stores the index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>. Return
No Clipper:
ORDSETFOCUS()
Set focus to an order in an order list


--------------------------------------------------------------------------------

Syntax

ORDSETFOCUS([<cOrderName> | <nOrder>]
[,<cOrderBagName>]) --> cPrevOrderNameInFocus

Arguments

<cOrderName> is the name of the selected order, a logical ordering
of a database. ORDSETFOCUS() ignores any invalid values of
<cOrderName>.

<nOrder> is a number representing the position in the order list of
the selected order.

<cOrderBagName> is the name of a disk file containing one or more
orders. You may specify <cOrderBagName> as the file name with or
without the path name or appropriate extension. If you do not include
the extension as part of <cOrderBagName>, CA-Clipper uses the default
extension of the current RDD.

Returns

ORDSETFOCUS() returns the order name of the previous controlling order.

Description

ORDSETFOCUS() is an order management function that returns the order
name of the previous controlling order and, optionally, sets the focus
to an new order.

If you do not specify <cOrderName> or <nOrder>, the name of the
currently controlling order is returned and the controlling order
remains unchanged.

All orders in an order list are properly updated no matter what
<cOrderName> is the controlling order. After a change of controlling
orders, the record pointer still points to the same record.

The active RDD determines the order capacity of an order bag. The
default DBFNTX driver only supports single-order bags, while other RDDs
may support multiple-order bags (e.g., the DBFCDX and DBPX drivers).

Note: ORDSETFOCUS() supersedes INDEXORD().

Examples

USE Customer VIA "DBFNTX" NEW
SET INDEX TO CuAcct, CuName, CuZip
? ORDSETFOCUS("CuName") // Displays: "CuAcct"
? ORDSETFOCUS() // Displays: "CuName"
Tava convertendo um sistema e dava um erro de execução, quando troquei as funções ai deu certo.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 04 Jan 2010 18:08
por alaminojunior
Credo !
Então se eu for migrar para o Harbour, vou ter dor de cabeça. Pois eu só uso OrdSetFocus() em xHarbour com a sintaxe que herdei do Clipper.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 04 Jan 2010 23:15
por alxsts
Olá!
Sintaxe Harbour: OrdSetFocus( [<nOrder>|<cIndexName>], [<cIndexFile>] ) --> cOldIndexName

Sintaxe Clipper: ORDSETFOCUS([<cOrderName> | <nOrder>] [,<cOrderBagName>]) --> cPrevOrderNameInFocus

Notem que tanto o primeiro quanto o segundo parâmetro recebido pela função é opcional (estão entre colchetes [] em ambas as sintaxes). Caso o primeiro parâmetro seja informado, notem também a presença do caracter pipe ( "|" ),indicando que podemos opcionalmente fornecer um número (número da ordem a selecionar) ou uma string (nome da ordem a selecionar).

O retorno é sempre uma string contendo o nome da ordem anteriormente ativa ou "" se nenhuma.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 05 Jan 2010 11:18
por clodoaldomonteiro
Hum! Entendi Alx.
No meus fontes em clipper estavam assim: ordsetfocus("1"), antão quando em converti para xHarbour tinha que verificar se existia um nome para o index.

Alamino!
Eu falei Harbour anteriormente, mas é no xHarbour, que é a mesma coisa, eu acho.

Re: DbSetOrder ou OrdSetFocus() ?

Enviado: 05 Jan 2010 12:58
por alxsts
Olá!
clodoaldomonteiro escreveu:No meus fontes em clipper estavam assim: ordsetfocus("1")
Achei estranho... Creio que não funcionava e você não percebeu.

Se você estivesse utilizando o RDD padrão (DBFNTX), o parâmetro "1" apontaria para o arquivo de índice 1.NTX...
Já com o RDD DBFCDX apontaria para a ordem nomeada "1" dentro do índice estrutural ativo...

Conforme a documentação, quando o primeiro parâmetro é passado como string e o arquivo de índice ou a ordem solicitada (dentro do índice estrutural) não são encontrados, a função simplesmente ignora o parâmetro.
Arguments

<cOrderName> is the name of the selected order, a logical ordering
of a database. ORDSETFOCUS() ignores any invalid values of
<cOrderName>
.