Date
1 - 10 of 10
Is there a way to get only variables on from from MAIN table? #xpa
Adrian Wick
Is there a way to only get displayed variable on a form from main table? without links ...
Thank you. A |
|
Frederik Soete
Hi, Adrian, Do you mean their VarCurr(VAR) values? DataViewVarsIndex(...) and DataViewVars(...) can return the visible variables' indexes and names (without the filename part). On the other hand VarName(VAR) returns the name with the filename part. E.g. VIRTUAL.FIRST or MYFILE.MYFIELD. For each variable you could determine the filename part. First real variable would most likely have main file name. Linked files would most likely have differring filename. This is just a rule of thumb, with lots of possible exceptions, depending on how you write code. That way you can get something like you wish, but it won't be easy or won't wirk perfectly. Bye, FS Is there a way to only get displayed variable on a form from main table? without links ... |
|
Adrian Wick
Yeah I thought so ...
Thank you for the answere. Regards. A |
|
Adrian Wick
Well it was easier than I thought it would be ...
All you need is : 1. Main table name which is easily obtained via VarName(). 2. DataViewVars() to get all the variables on screen populated into a vector. 3. Loop trough vector to get each name 4. Use VarIndex() from point 3 (don't forget to trim() that sucker) 5. StrToken() point 4 to get the name and compare it with the name from point 1. If equals, write it to the table ... And it's done. Regards, A |
|
Frederik Soete
Hi Adrian Congrats for getting the general case right. If I may be so curious: why have you come to need this trick? --- Exceptions I could mention: - what if a virtual or a link is positioned above the first main field. - what if one or more links refer to the same file as the main file. Those cannot normally be detected. Our app in some places has such exceptions. But YMMV: not everyone needs such exotic code... Bye, FS Op zo 22 jan. 2023 07:41 schreef Adrian Wick <adrian.wick2015@...>: Well it was easier than I thought it would be ... |
|
Pavel Mencl
VarName gives you a "full name" (=including its origin) whileDataViewVars only "short" names.
I've been wondering what is the reasoning behind such design? Pavel |
|
Frederik Soete
Hi Pavel, If you do not avoid dots in filenames and fieldnames, StrToken won't work for parsing a VarName. So then it's handy to have a short name. Secondly, the short names are necessary in the current implementation of exporting a dataview: DataViewToDNTable etc. There could be other uses... Byes, VarName gives you a "full name" (=including its origin) whileDataViewVars only "short" names. |
|
Pavel Mencl
Yes, that makes sense.
Thanks Pavel |
|
At first I thought about changing the XPAs "range" filter (ctrl+R) which you can change in the "UserFunctionality".
And than I realized not everybody would want that to be changed. So I decided to make my own "range". As I dug into it, I realized I wont be able to use this as a global even since I would have to go and change all queries into left joins ... So for the main table that is not the case. The only problem I see now is if, somehow, I have a link query into the same table as my main table (I am 99,99% sure that is not the case). So what I do now is write up a memory table with fields from main table, the user can than enter search words in the corresponding fields without needing to click on the drop down and than selecting the field. And at the end I have a drop down for the user to choose how to filter results from 2 fields, do they want AND or do they want OR behavior ... From all that I simply create a "WHERE statement" and return it as a parameter. In all of the programs that I want to use this I will put a variable in "SQL WHERE". And compared to the original CTRL+R, its quicker to make a filter selection. Will test it this week and see how it goes :D Regards, A |
|
Adrian Wick
@Frederik Soete
1. It doesn't matter if there is a link above the 1st variable of a main table ... I have to send the parameter and that parameter is always a variable from main table ... 2. Yes, I also have link query into the same table (rare examples), but I never have it displayed on the form ... I thought about it and I could not come up with the answer why would I need to display a different record from a table on the form. If I do come up with this problem, I will deal with it later on. Regards, A |
|