Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Refreshing cursoradapter after changing 'order by' claus
Message
 
To
17/09/2003 05:14:37
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00829310
Message ID:
00830226
Views:
17
Hi Agnes !

I found the reason why my code did not work.
Result of command THIS.SELECTCMD = "SELECT * FROM MyTable &lcMacro"
depends on if lcMacro variable is visible to the command.
If lcMacro is visible (in scope) and for example lcMacro = "" then we will have such value of SELECTCMD property "SELECT * FROM MyTable". If lcMacro variable is not visible (not in scope) will have such value of SELECTCMD property "SELECT * FROM MyTable &lcMacro". It seems that VFP reevaluate SELECTCMD property after assigning a value to it.
Now changing the order in the way works to me but I still have doubts if it is the proper way. In reality I use cursorrefresh method but I do not refresh the cursor only but in background I also coerce the change its base property (select command). It seems like a trick or even an abuse.

Best Regards




>Hi Jozef,
>
>
>>Solution with using makro works only in conjunction with cursorfill method.
>
>????
>
>It works with cursorrefresh. I have done it.
>
>look at my Example
>
>LOCAL;
> lcMacro   AS CHARACTER,;
> loAdapter AS CURSORADAPTER
>
>
>CREATE CURSOR myTable (c1 C(1), c2 C(3))
>INSERT INTO myTable VALUES ("A","1")
>INSERT INTO myTable VALUES ("B","2")
>INSERT INTO myTable VALUES ("C","3")
>
>loAdapter = NEWOBJECT('captest')
>
>lcMacro = ''
>loAdapter.CURSORFILL()
>SELECT (loAdapter.ALIAS)
>BROWSE
>lcMacro = 'ORDER BY 1 DESC'
>loAdapter.CURSORREFRESH()
>BROWSE
>
>DEFINE CLASS capTest AS CURSORADAPTER
> PROCEDURE INIT
>  THIS.ALIAS          = 'capTest'
>  THIS.DATASOURCE     = 'Native'
>  THIS.DATASOURCETYPE = 'Native'
>  THIS.SELECTCMD      = "SELECT * FROM MyTable &lcMacro"
> ENDPROC &&INIT
>ENDDEFINE
>
>all what you have to care is, that SELCTCMD holds the &lcMacro, not the expanded string.
>
>Agnes
>>I was looking for something that work in conjunction with cursorrefresh method because I want to avoid repopulating columns of a grid displaying data from the cursor as it must be done in case of usuing cursorfill method.
>>Repopulating columns of the grid is quite easy and it seems that I will do that because cursorrefresh method is not as smart as I thought it is.
>>Have a nice day !
>>
>>>Good Morning Jozef!
>>>
>>>What I do is to add a macro to the SELECTCMD like
>>>
>>>
>>>.SELECTCMD = "SELECT * FROM MyTable &lcMacro'
>>>
>>>
>>>There should exist no var named lcMacro in the moment you execute the command above!
>>>
>>>Before CursorFill and CursorRefresh set lcMacro to a appropriate value, even to an empty string.
>>>
>>>(This as well will do very dynamic WHERE clauses, that is what I use it for)
>>>
>>>
>>>HTH
>>>Agnes
>>>
>>>>Hi !
>>>>1.I want to change "order by ..." clause - included in cursoradapter SelectCmd property - based on a selection made by user. After making such change how should I refresh underlaying cursor ? CursorRefresh method seems not work in such case ( cursorFill works but it close the cursor and destroy grid layout).
>>>>2. I wonder why it is not possible to make such things using parameters like it is in case of 'where ...' clause. Does anybody knows the reason.
>>>>'Order by' clause look simpler than 'where ...' clause
>>>>
>>>>Thanks in advance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform