Page 1 of 2

Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 6:09 am
by AUGE_OHR
hi,

i got this Error
SetIndex.JPG
SetIndex.JPG (19.79 KiB) Viewed 2600 times
but i don´t understand while it work when only 1 x Index is used

Code: Select all

SetNewIndex(cPath)
cRet := SP_GetWahl()

BEGIN SEQUENCE
   SET INDEX TO &cRet
   lRet := .T.
   Domethod( "Browse_View", "BrowserView", "Refresh" )
END SEQUENCE
i add full path and "," if need

Code: Select all

FUNCTION SetNewIndex(cPath)
...
FOR i := 1 TO iMax
   nRow := aRow[i]
   cItem := TRIM( aSort[ nRow ] [ 1 ] )
   cRet += cPath+cItem
   IF i <> iMax
      cRet += ", "
   ENDIF
NEXT
SP_GetWahl( cRet )
so what do i miss :idea:

p.s. i´m sure that Index belong to DBF

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 7:45 am
by dragancesu
_dbf1 = 'cust'
_ntx1 = 'cust'
_ntx2 = 'custn'

use &_dbf1 index &_ntx1, &_ntx2

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 8:40 am
by AUGE_OHR
hi,

have made a Demo
SETINDEX.ZIP
(2.09 KiB) Downloaded 138 times
try to select more that 1 x NTX

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 9:08 am
by gfilatov
AUGE_OHR wrote: Mon Feb 03, 2020 8:40 am hi,

have made a Demo
SETINDEX.ZIP

try to select more that 1 x NTX
Hi Jimmy,

Please try the updated function below:

Code: Select all

STATIC PROCEDURE Pre_SetNewIndex( cDBF )

LOCAL cRet   := ""
LOCAL lRet   := .F.
LOCAL bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )

   SP_GetWahl( "" )
   SetNewIndex( cDBF )
   cRet := SP_GetWahl()

   IF !EMPTY( cRet )
      BEGIN SEQUENCE
         SET INDEX TO &cRet
         lRet := .T.
      END SEQUENCE
      ERRORBLOCK( bError )

      IF lRet = .F.
         MsgInfo( "Error set Index TO " + CRLF + cRet )
      ELSE
         dbSetOrder( OrdCount() )
         dbGoTop()
         Browse_View.BrowserView.VALUE := RecNo()
         Browse_View.BrowserView.REFRESH
      ENDIF
   ENDIF
RETURN
:idea:

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 9:31 am
by dragancesu
I don't know what kind of users you have, but this is not the clearest solution, I think: let the user choose the file that will be indexed / displayed is not good solution

If you have more indexes then make for each button, one for the key, one for the name, one for the address, city, price, something third

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 9:33 am
by AUGE_OHR
hi,
gfilatov wrote: Mon Feb 03, 2020 9:08 am
Please try the updated function below:

Code: Select all

STATIC PROCEDURE Pre_SetNewIndex( cDBF )
      BEGIN SEQUENCE
         SET INDEX TO &cRet // here is my Problem
         lRet := .T.
      END SEQUENCE
      ERRORBLOCK( bError )
      IF lRet = .F.
         MsgInfo( "Error set Index TO " + CRLF + cRet )
      ELSE
thx for Answer

my Problem is before ELSE
as my Picture show i got a Error so i does not come to ELSE
it will Crash without BEGIN SEQUENCE but Errorlog.HTM does not tell me "why" :(

as i remember i can write

Code: Select all

SET INDEX TO C:\MyDir\AAA.NTX, C:\MyDir\BBB.NTX
and cRet String "seems" me OK in Debugger ...

what do i miss :idea:

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 9:47 am
by AUGE_OHR
hi,
dragancesu wrote: Mon Feb 03, 2020 9:31 am I don't know what kind of users you have, but this is not the clearest solution, I think: let the user choose the file that will be indexed / displayed is not good solution

If you have more indexes then make for each button, one for the key, one for the name, one for the address, city, price, something third
i agree and understand but "this" is not a "User-Tool" ;)

DBF Part is more like DBU where you get same List of Index.
also "MODI STRU" (under construction) is not for User.
F4 is only for Admin who know what he is doing.

p.s. i have to search but i think a have a Modul for CLICK to "identify" NTX Indexkey without SET INDEX

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 10:44 am
by dragancesu
Ok, understand

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 2:21 pm
by gfilatov
AUGE_OHR wrote: Mon Feb 03, 2020 9:33 am hi,
...
my Problem is before ELSE
as my Picture show i got a Error so i does not come to ELSE
it will Crash without BEGIN SEQUENCE but Errorlog.HTM does not tell me "why" :(

what do i miss :idea:
Hi,

OK, try the follwong fixed function:

Code: Select all

STATIC PROCEDURE Pre_SetNewIndex( cDBF )

LOCAL cRet   := ""
LOCAL lRet   := .F.
LOCAL bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )

   SP_GetWahl( "" )
   SetNewIndex( cDBF )
   cRet := SP_GetWahl()

   IF !EMPTY( cRet )
      BEGIN SEQUENCE
         ordSetFocus( 0 )
         SET INDEX TO &cRet ADDITIVE
         lRet := .T.
      END SEQUENCE
      ERRORBLOCK( bError )

      IF lRet = .F.
         MsgInfo( "Error set Index TO " + CRLF + cRet )
      ELSE
         dbGoTop()
         Browse_View.BrowserView.VALUE := RecNo()
         Browse_View.BrowserView.REFRESH
      ENDIF
   ENDIF
RETURN
It works fine for the three index files here... :arrow:

Re: Macro SET INDEX TO &more_than_one

Posted: Mon Feb 03, 2020 10:54 pm
by AUGE_OHR
hi,
gfilatov wrote: Mon Feb 03, 2020 2:21 pm OK, try the follwong fixed function:

Code: Select all

         ordSetFocus( 0 )
         SET INDEX TO &cRet ADDITIVE
It works fine for the three index files here... :arrow:
did you select more than 1 x NTX :?:

i have try your Code but it does not Change the Error Message ...