Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using UDFs in grids

Posted on 2014-10-19
3
Medium Priority
?
286 Views
Last Modified: 2014-10-19
I'm having a problem with a column in a grid, which I want to display the results of a UDF.

I've got this column defined in the .INIT() method as using

    .ControlSource = "inttohex(VAL(names.value),4)"

- where inttohex() is a UDF that converts an integer into a hexadecimal string. The UDF takes two parameters. First is the integer, here the numeric contents of the NAMES.VALUE filed. The second parameter is the width of the resulting string.

I've include a declaration in the .INIT() method code as

    EXTERNAL PROCEDURE inttohex

When I run this, I get an error:

    Variable is not found

The call stack is pointing to the line which defines the .ControlSource property.

Any suggestions?
0
Comment
Question by:IainMacb
3 Comments
 
LVL 43

Accepted Solution

by:
pcelba earned 1000 total points
ID: 40390095
You should enclose the ControlSource expression into parentheses:

    .ControlSource = "(inttohex(VAL(names.value),4))"

or

    .ControlSource = "(TRANSFORM(VAL(names.value), '@0'))"

The EXTERNAL PROCEDURE command is not necessary here.
0
 
LVL 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 1000 total points
ID: 40390122
As Pavel says. It's a bug of VFP9, it's defined as "by design", but it hasn't always been that way, this controlsource could have worked in earlier versions.

The problem VFP9 has, is: It could interpret inttohex (or any function name) as an array variable, parameters of the function call interpreted as indexes of an array variable. Putting an expression into outer paranthesis solves the problem.

Explanation I got some time ago: A controlsource in paranthesis is by definition an expression evaluated, leading to a readonly controlsource (oneway), while anything that could be a variable or array element could also be bound twoway (read/write). VFP then gives up stating "Variable not found".

It makes sense halfways, but in any other place in code that expression would be evaluated without the error.

Parenthesis are a general solution, if you bind to such an expression or anything else but variables or fields you want to bind to read/write. Even if you want to bind a field or variable readonly, you can do so with parenthesis.

Bye, Olaf.
0
 
LVL 1

Author Closing Comment

by:IainMacb
ID: 40390329
Wow for speed of response! :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I showed you how to use console view (HERE (http://www.experts-exchange.com/articles/18379/Getting-Started-and-Using-the-Salesforce-com-Console.html)) -– but how do you set it up on the admin side of Salesforce? Note that you have to have Admin leve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question