Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tweak the Expression Builder Dialog Box _GETEXPR

Status
Not open for further replies.

avsalf

Programmer
Oct 19, 2009
18
CO
Does anyone have a template or example of BuilderProgram to customize
_getexpr = "mygenBuilderProgram"

GETEXPR [cCaptionText] TO MemVarName
[TYPE cExpressionType [; cErrorMessageText]] [DEFAULT cDefaultExpression]


SOMETHING LIKE THIS:

PROCEDURE mygenBuilderProgram
PARAMETER cExpressionType,cErrorMessageText,cDefaultExpressio
DO FORM MYGETEXPR
RETURN RETMEMVAR

snap1903_tgobki.jpg
 
So what exactly are you trying to achieve? Do you want to: (i) create your own expression builder form? Or (ii) call the existing expression builder programmatically, allow the user to interact with it, and then get the result of the expression?

I'm assuming it is (ii). If so, you are basically on the right track, but you don't need DO FORM, and your RETURN statement is incorrect. I think you need something like this:

Code:
PROCEDURE mygenBuilderProgram
PARAMETER cExpressionType,cErrorMessageText,cDefaultExpression
LOCAL RetVal
GETEXPR "My Expression Builder" TO RetVal ;
  TYPE "cExpressionType; cErrorMessageText" DEFAULT cDefaultExpression
RETURN RetVal

You would then call the procedure something like this:

Code:
? mygenBuilderProgram("C", "Invalid Expression", "")

However, if the answer to my question is (i), then you need to design your own form. In that case, there is not much point in using the Expression Builder. Just create a form that does what you want, and let it return a result.

EDIT: Sorry, slight mistake in above code. Now corrected.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The topic "_GETEXPR System Variable" has all you need to know.

The simplest example would be a prg with following code:

Code:
Lparameters tcExpressionType, tcErrorMessageText, tcDefaultExpression, tcCaptionText

Return "42"

The help also tells you, that whenever you click a button in the IDE like the [fx] Button in the properties window, this PRG gets called and if at all, you only get the tcCaptionText parameter set to what caption the usual expression builder would set above the expression EditBox.

You're free to call whatever form or EXE from that PRG, it should just be modal, and in the end, your PRG has to return the expression. For sake of clarity: An expression, a string that will evaluate to the wanted type. Whether the type is correct will be judged by VFP (I assume it will check VARTYPE(EVAL(expression)) so in any case, you could disregard the parameters, but the PRG has to have the 4 parameters. The caption would not even need to be taken seriously, VFP will not see whether you use it or not.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Thank Mike & Olaf, yes, i am try create my own expression builder form to end user with one data diccionary. for filter report sccreens and Query by example.
snap1983_c3qedi.jpg
 
Well, if I understand you right, this is just a normal form. The job of the form might well be to build an expression, but it has nothing to do with VFP's built-in Expression Builder.

If that's right, I suggest you forget about GENEXPR. That will just confuse the issue. Focus on creating a form that lets the user select the fields and specify the relationships, and which then builds a SQL statement based on the user's input. In fact, judging from your screen shot, you have already done that.

The only exception would be if you wanted to invoke your custom form from within the VFP IDE, for example from the Properties window or the Report Designer. But that doesn't seem likely, based on what you have told us.

Another option would be to use VFP's built-in Query Designer, which will actually generate the SQL for you. But that would only be of any use within the IDE.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

look into _GETEXPR and you see this way you integrate into the VFP IDE. I agree, if this is only part of mn application there is no need to integrate into this, you just do your thing and can decide how you call and use it. But it may be a wanted side effect to enhance the IDE Expression Builder by swapping it with something better. And then you can use GETEXPR with a _GETEXPR set to your prg to trigger it or make your own DO FORM call, that's up to you. But the IDE will only call your replacement form from the buttons the IDE has in several places you can call the Expression Builder or via GETEXPR command.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Gracias, por los comentarios, voy a terminarlo y lo colocare aquí para si alguien lo quiere tomar o complementar.
 
OK, looking forward to see your final builder.

Implementing it in any way, no matter if by the IDE norm or your own choice, in the end you'll want an expression you can put into code, a query, a property, whatever. And then it's just the step of putting all that into a PRG and return the expression and it integrates into the IDE, too. That doesn't make it simpler nor more complicated and so why not, Mike? Many others will benefit, on top you can actually use the GETEXP command to use your own form via that "contraption", and while it may be a bit more complicated than doing it directly and only for your own applications' needs, it's not much on top.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top