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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setgenfilter with a boolean/logical value

Status
Not open for further replies.

GraemeOswald

Programmer
Feb 28, 2002
3
0
0
GB
Hi,
I've just "inherited" a paradox application, and there are a few bugs in it which I'm trying to fix. The one which looks like it should be easy, but I've had a real struggle with is represented by the following snippet:
Code:
var
	arRangeInfo  	DynArray[] AnyType
	tblTC	TCursor
endVar

Switch
	Case ActiveButton = TRUE AND InactiveButton = FALSE:
		arRangeInfo["Complete"] = FALSE
	Case ActiveButton = FALSE AND InactiveButton = TRUE:
		arRangeInfo["Complete"] = TRUE
	Otherwise:
		arRangeInfo["Complete"] = ""
endSwitch

TblTC.setGenFilter(arRangeInfo)
which by my (admittedly limited) understanding, should apply a filter to the table cursor on the "Complete" column which is a Logical, whenever certain buttons are pressed.

However, under Paradox 10, I always get a run-time error on the 'setGenFilter' method saying something like 'Filter expression is not valid' and then 'Can't convert True to a fldBool' and then 'Invalid Character "T"rue'.

I've tried various combinations of Logical(True), string(Logical(True)), 0, 1, string("\\0") (and many others) but nothing seems to work.

Any suggestions?

Graeme
 
Wild shot, since it's late tonight....
Put some inverted commas around the true and false values, e.g. arRangeInfo["Complete"] = "FALSE"
otherwise try values like 0 and -1.
HTH
 
I am having the same problem, but with a twist. I have two copies of the same form, with some minor changes in code on some objects. There is a pushbutton to ui.switchIndex() which is the same on both. On Form1 the code works like a charm and the subsequent ui.setGenFilter(dyn) works. But on Form2 I get the error message: Can't convert Yes to fldBool then Invalid character "Y"es

So this one is quite a conundrum.
 
Can we see the code?

It sounds like a syntax error somewhere.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Also - I have found that if the value is to be of Logical Type it is best to define it as: Logical(true), instead of simply assigning it the string value of "True" or "Yes".

i.e.

var
mySwitch Logical
endvar

mySwitch = Logical(true)

view(mySwitch)

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Here is the code on the Pushbutton. The field object is called "Current".

var
ui uiObject
endVar

ui.attach(Current)
if ui.switchIndex("CurrentStudent") then
else errorShow()
endIf

The error occurs directly on the switchIndex command.

 
Okay, now show the code where the value of CurrentStudent gets assigned.

A quick value check might be in order. Try inserting:

view(CurrentStudent)

before the call to set the filter.



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
No values are being assigned. The field already has the values (showing "Yes" or "No" in the format of the logical field). As an interesting side-note, I could not interactively create the index (Logical,String,String) and had to use a script to CreateIndex from an array. The index can easily be activated in interactive mode (using Filter) and works on the 2nd instance of the form. Is it perhaps some form corruption?
 
It is possible that the form is corrupted, but I'd still like to know what the value of CurrentStudent is when the attempt to set the filter is made. Based on the error message it sounds as though it cannot change the string value "Yes" to a logical true; which would indicate that it does not recognize the Paradox logical constant. That seems very odd indeed. Look at the 'values' for the currentStudent button properties and make sure there are not some stray characters or quotes in there.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
I found the solution. Sort of a gotcha: In Form2 (non-working) I had set the form filter to True (Yes), so that the form opened (without code) to filter to Yes. Once I removed that the form worked fine. So there is a wierd interaction between the compiled form filter and the switchIndex(). So now I just the the filter to Yes on opening.
 
Cool - thanks for posting the solution. It was a puzzler.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Sonso,

In my experience, it's best to drop all active ranges and filters before delivering forms. I generally use scripts to manage this.

If you'd like to see an example, check out which has a download with a script you can modify for this task. While it was originally written for a slightly different task, it can be useful for this situation as well.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top