bruceR Posted February 9, 2011 Posted February 9, 2011 I have filed a bug report on this. GetNthRecord is completely unreliable, whether used in a script or custom function. It will return data from the current record, NOT from the Nth record. This script fails if you do not concatenate the empty string before the call to getNth. Tests with a recursive custom function also fail. Set Variable [ $$r; Value:"" ] Set Variable [ $k; Value:1 ] Loop Exit Loop If [ $k > Get(FoundCount) ] Set Variable [ $$r; Value:List( $$r; "" & GetNthRecord( Zips::city; $k)) ] Set Variable [ $k; Value:1 + $k ] End Loop
comment Posted February 9, 2011 Posted February 9, 2011 (edited) I believe this buglet has more to do with the List() function - or rather all aggregate functions - than GetNthRecord(). Edited February 9, 2011 by comment
bruceR Posted February 9, 2011 Author Posted February 9, 2011 Example file. Does it fail for you? Perhaps we will discover plugin dependencies or something? getNthFail.fp7.zip I believe this buglet has more to do with the List() function than GetNthRecord(). Mm, don't think so, take a look at the example file, which derives the getNth value outside of the list operation.
bruceR Posted February 9, 2011 Author Posted February 9, 2011 I believe this buglet has more to do with the List() function - or rather all aggregate functions - than GetNthRecord(). Thanks, can you expand on that? I do see that in the loop script, if I separately capture the value to a variable with a simple getNthRecord and then incorporate the result in the list function, it works OK. But in the custom function, the value is captured outside the list operation - but still fails.
comment Posted February 9, 2011 Posted February 9, 2011 I have a much simpler example (attached). It is also more frightening, because up until now I was convinced that dumping GetNthRecord() into a Let() variable first would solve the issue. It seems the evaluation order is not what one would expect. I doubt they will ever fix this, though, because it would probably take the speed out of all aggregate functions (this last is purely a speculation on my part). AggregateNthBug.zip
Raybaudi Posted February 9, 2011 Posted February 9, 2011 It seems that we need to declare the result of GetNth: GetAsNumber for comment's example GetAsText for Bruce's example
comment Posted February 9, 2011 Posted February 9, 2011 Well, you need to do something in order to get it to evaluate first. GetAsType(v) is just as good as "" & v or 0 + v. BTW, here's another fun example: define two fields as = Let ( t = GetNthRecord ( Textfield ; 1 ) ; List ( t ; GetAsText ( t ) ) ) and = Let ( t = GetNthRecord ( Textfield ; 1 ) ; Exact ( t ; GetAsText ( t ) ) ) then scroll through the records.
Recommended Posts
This topic is 5093 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now