Macro SET INDEX TO &more_than_one

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Macro SET INDEX TO &more_than_one

Post by AUGE_OHR »

hi,

i got this Error
SetIndex.JPG
SetIndex.JPG (19.79 KiB) Viewed 2598 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
have fun
Jimmy
User avatar
dragancesu
Posts: 930
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Macro SET INDEX TO &more_than_one

Post by dragancesu »

_dbf1 = 'cust'
_ntx1 = 'cust'
_ntx2 = 'custn'

use &_dbf1 index &_ntx1, &_ntx2
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Macro SET INDEX TO &more_than_one

Post by AUGE_OHR »

hi,

have made a Demo
SETINDEX.ZIP
(2.09 KiB) Downloaded 137 times
try to select more that 1 x NTX
have fun
Jimmy
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Macro SET INDEX TO &more_than_one

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
dragancesu
Posts: 930
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Macro SET INDEX TO &more_than_one

Post 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
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Macro SET INDEX TO &more_than_one

Post 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:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Macro SET INDEX TO &more_than_one

Post 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
have fun
Jimmy
User avatar
dragancesu
Posts: 930
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Macro SET INDEX TO &more_than_one

Post by dragancesu »

Ok, understand
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Macro SET INDEX TO &more_than_one

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Macro SET INDEX TO &more_than_one

Post 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 ...
have fun
Jimmy
Post Reply