Reply To: Is there a macro that will cycle thru Random Access Marks?

Product Compare Forums Multi-Edit Support Is there a macro that will cycle thru Random Access Marks? Reply To: Is there a macro that will cycle thru Random Access Marks?

#6286
John Martzouco
Participant

Thanks David… nice routine. I added some code to it and now I have wraparound in both directions:

[code:271mj9vh]
{
struct edxmark m;
int i, j = -1;
int line, col, row, offset;
int nReverse = 0;
struct edxmark sWrapPos; // will only use slot 0 save lowest or highest mark for wraparound
int nWrapMark = -1;

// initialize the wraparound structure for first loop
if (nReverse == direction)
{
sWrapPos.line[0] = -1;
sWrapPos.col[0] = -1;
}
else
{
sWrapPos.line[0] = 999999;
sWrapPos.col[0] = 999999;
}

for (i=0; i<=9; ++i)
{
Get_Mark_Record(i+1, 2, line, col, row, offset);
m.line[i] = line;
m.col[i] = col;

if (line > 0) //if mark is set
{
IF (direction == nReverse)
{
// capture highest for wraparound (this is the test from FORWARD)
if ((sWrapPos.line[0] < m.line[i]) || ((sWrapPos.line[0] == m.line[i]) && (sWrapPos.col[0] < m.col[i])))
{
nWrapMark = i;
sWrapPos.line[0] = m.line[i];
sWrapPos.col[0] = m.col[i];
}

/*
REVERSE
IF MARK[I] < CURRENT POSITION
THEN
IF J==-1 THEN J=I
ELSE
IF MARK[I] > MARK[J] THEN J=I
*/
If ((m.line[i] < C_Line) || ((m.line[i] == C_Line) && (m.col[i] < C_Col)))
{
if (j == -1){j = i;}
else if ((m.line[i] > m.line[j]) || ((m.line[i] == m.line[j]) && (m.col[i] > m.col[j]))){j = i;}
}
}
ELSE
{
// capture lowest for wraparound (this is the test from REVERSE)
if ((sWrapPos.line[0] > m.line[i]) || ((sWrapPos.line[0] == m.line[i]) && (sWrapPos.col[0] > m.col[i])))
{
nWrapMark = i;
sWrapPos.line[0] = m.line[i];
sWrapPos.col[0] = m.col[i];
}

/*
FORWARD
IF MARK[I] > CURRENT POSITION
THEN
IF J==-1 THEN J=I
ELSE
IF MARK[I] < MARK[J] THEN J=I
*/
If ((m.line[i] > C_Line) || ((m.line[i] == C_Line) && (m.col[i] > C_Col)))
{
if (j == -1){j = i;}
else if ((m.line[i] < m.line[j]) || ((m.line[i] == m.line[j]) && (m.col[i] < m.col[j]))){j = i;}
}
}
}
}

// try and see if we have a wraparound in memory
if (-1 == j)
{
j = nWrapMark;
}

IF (j != -1)
{
Get_Mark(j+1);
}
ELSE
{
if (direction == nReverse){
make_message("No markers in reverse direction.");
}else{
make_message("No markers in forward direction.");
}
}
}
[/code:271mj9vh]