void *Getsortedbyselection(t_sorted *sd,int index);
Locates index-th item in the table of the sorted data sorted by the currently selected criterium. Parameter index is usually the 0-based index of the selected line (sd->selected), hence the name.
Parameters:
sd
(in) Pointer to the structure of type t_sorted, descriptor of sorted data
index
(in) Index of the item in the sorted data sorted by sd->sort
Return values:
On success, returns pointer to the element of sorted data. On error, returns NULL.
Example:
Here is the slightly modified code of the function that executes command "Dump in CPU" in the Memory window. User selects line in the table, calls pop-up menu and clicks on "Dump in CPU". The function then opens pointed memory block in the CPU Dump pane.
static int Mdumpincpu(t_table *pt,wchar *name,ulong index,int mode) {
t_memory *pmem;
if (pt==NULL)
return MENU_ABSENT;
pmem=(t_memory *)Getsortedbyselection(&(pt->sorted),pt->sorted.selected);
if (pmem==NULL)
return MENU_ABSENT;
if (mode==MENU_VERIFY)
return MENU_NORMAL;
else if (mode==MENU_EXECUTE) {
Setcpu(0,0,pmem->base,0,0,CPU_DUMPHIST|CPU_DUMPFOCUS);
return MENU_NOREDRAW; }
else return MENU_ABSENT;
};
static int Mdumpincpu(t_table *pt,wchar *name,ulong index,int mode) {
t_memory *pmem;
if (pt==NULL)
return MENU_ABSENT;
pmem=(t_memory *)Getsortedbyselection(&(pt->sorted),pt->sorted.selected);
if (pmem==NULL)
return MENU_ABSENT;
if (mode==MENU_VERIFY)
return MENU_NORMAL;
else if (mode==MENU_EXECUTE) {
Setcpu(0,0,pmem->base,0,0,CPU_DUMPHIST|CPU_DUMPFOCUS);
return MENU_NOREDRAW; }
else return MENU_ABSENT;
};
See also:
Sorted data, t_sorted, Createsorteddata(), Findsorteddata(), Findsorteddatarange(), Findsortedindexrange(), Getsortedbyindex(), Sortsorteddata()