Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Refreshing cursoradapter after changing 'order by' claus
Message
 
À
19/09/2003 01:53:40
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00829310
Message ID:
00830580
Vues:
32
Hi Agnes !
1. It seems that I must read your posts more carefully.
2. As regards as makro. I never used makro in such way and that is the reason why it was a discovery for me. I used it only in places limited to those described in VFP help in such way:
"Macro substitution treats the contents of a variable or array element as a character string literal. When an ampersand (&) precedes a character-type variable or array element, the contents of the variable or element replace the macro reference".
In case of string like "SELECT * FROM MyTable &lcMacro" the ampersand syntacticly did not precede variable name. It precede a part of character string literal. However I found such short sample in VFP help:
x = "Fox"
? "&x.Pro"
(BTW for me it is good example of an unreadable code why not ?
x = "Fox"
? x + "Pro" )
IMHO evaluating makro placed inside string literal is a quite unnecessary VFP feature. Despite this, it seems that you are right again. Fox work in such way since DOS times. I should know about it. Thanks and have a nice weekend !


>Good Morning Jozef,
>
>It seems that I have not made this point as strong as it has to be.
>
>from below:
>>>>>
>>>>>.SELECTCMD = "SELECT * FROM MyTable &lcMacro'
>>>>>
>>>>>
>>>>>There should exist no var named lcMacro in the moment you execute the command above!
>
>what means exactly what you have figured out.
>
>This behaviour is general to string commands.
>
>Agnes
>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform