SOLVED: First and Next Selected Line

CarolineTweedle
CarolineTweedle Posts: 3 Calcite Rank Badge
edited February 2023 in GeoStudio
Hi all,

I recently created a button attached to a gx that would scroll through the selected lines in a project (as opposed to the next line). It was a very simple code and seemed to work fine.

EData = Current_EDB();
Line = GetCurLineSymb_EDB(EData);

Data = Lock_EDB(EData);

Line = NextSelLine_DB(Data,Line);

UnLock_EDB(EData);
GotoLine_EDB(EData,Line);

However, since the update to 9.5.2 the button is no longer scrolling through the lines sequentially. The NextSelLine function seems to choose a random line from the selection set. I have even tried looking at the line handle to see if it is moving through in a sequential order but it isn't. Does anyone have any ideas please?

TIA

SOLUTION FOUND
Hi all.
It appears that the NextSelLine function was not working as I anticiapted. I thought it would move through in line number order but it appeared to be moving through in line handle order. This was not changed by rolling back versions so I assume that the original test database coincidentally had line numbers that were in the same order as the line handles. To check this, you can interrogate the line handle number through the debugger tool.

I have now re-written the code using the SelectedLineLST_DB(Data,List) function. This gets a list of selected line and their handles. The whole code now reads:

EData = Current_EDB(); //get current edb

Line = GetCurLineSymb_EDB(EData); //get current line handle

Data = Lock_EDB(EData); //lock edb

List = Create_LST(1056); //create list
SelectedLineLST_DB(Data,List); // Get selected line names and handles into list

GetSymbName_DB(Data,Line,sLine); //get the name of the current line

i = iFindItem_LST(List,0,sLine); //find current line name in list and returns item index number
n = iSize_LST(List); //get total size of list

GtSymbItem_LST(List,i+1,sLine,1056,Line); // Get next symbol handle based on previous line number

//if the line is the last in the list, return to the first line and give a message to the user

if (i == n-1) {
DisplayMessage_SYS("Information","This is the last selected line in the database - returning to first selected line");
}



UnLock_EDB(EData); //unlock the database
GotoLine_EDB(EData,Line); //go to the next line

Destroy_LST(List); //destroy list item
This discussion has been closed.