Page 1 of 1
PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 3:14 pm
by THCM
SortStructuredArray(PeriodsUsage(), #PB_Sort_Descending, OffsetOf(PeriodStats\PeriodCount), #PB_Sort_Long)
The compiler stops with constant not found error: #PB_Sort_Long and the autocomplete funtion of the IDE only suggests #PB_Sort_Long as #PB_Sort_ type. Perhaps something has changed here?
Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 3:22 pm
by Demivec
The 'Sort' types now match the variable types. So #PB_Sort_Long would be replaced by #PB_Long.
@Edit: corrected a silly typo.
Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 3:24 pm
by THCM
Thx, this works fine!
Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 4:07 pm
by c4s
This has already changed in PB 5.10

Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 4:49 pm
by THCM
Maybe, but the source compiles with 5.11 without errors...
Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 4:49 pm
by Little John
In newer PB versions, it's not necessary at all to use those type constants.
TypeOf() does the job.
Actually, normally I'm using a macro like this:
Code: Select all
Macro SortStructuredArraySimple (_ArrayName_, _Options_, _Structure_Field_)
SortStructuredArray(_ArrayName_, _Options_, OffsetOf(_Structure_Field_), TypeOf(_Structure_Field_))
EndMacro
SortStructuredArraySimple(PeriodsUsage(), #PB_Sort_Descending, PeriodStats\PeriodCount)
This macro also shows how calling the built-in PB functions
SortStructuredArray() and
SortStructuredList() could be simplified.
Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Thu Jun 20, 2013 4:55 pm
by c4s
@Little John
Great idea!
Re: PB5.20b1 - SortStructuredArray throws an error
Posted: Fri Jun 21, 2013 8:46 am
by THCM
Nice one!