GotoRow - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

Result

 GotoRow
 move the cursor to the given row

 Calling Sequence result:-GotoRow(offset, opts )

Parameters

 result - Result module offset - integer; the index of the row opts - (optional) equation of the form relative=boolean

Description

 • GotoRow moves the row cursor maintained within result to the row indexed by offset.  If offset is positive, then it is interpreted to be relative to the beginning of the table.  GotoRow(1) is the first row, GotoRow(2) is the second, and so forth.  If offset is negative, then it is interpreted to be relative to the last row of the table.  GotoRow(-1) is the last row, GotoRow(-2) is the second to last row.
 • The index of the current row can be obtained by calling GetRowIndex.
 • GotoRow accepts one optional argument.
 relative = boolean
 If relative is true, then offset is interpreted as relative to the current row.  For example, GotoRow(1,relative=true) is equivalent to Next.
 • Setting the row cursor to a location beyond the ends of the table results in the cursor getting set to the row before the first data row or the row after the last data row.

Examples

Create a Result.

 > $\mathrm{driver}≔{\mathrm{Database}}_{\mathrm{LoadDriver}}\left(\right):$
 > $\mathrm{conn}≔\mathrm{driver}:-\mathrm{OpenConnection}\left(\mathrm{url},\mathrm{name},\mathrm{pass}\right):$$\mathrm{res}≔\mathrm{conn}:-\mathrm{ExecuteQuery}\left("SELECT name FROM animals"\right):$

Notice the order of names.

 > $\mathrm{res}:-\mathrm{ToMaple}\left(\mathrm{output}='\mathrm{Array}'\right)$
 $\left[\begin{array}{c}{"fish"}\\ {"dog"}\\ {"cat"}\\ {"rat"}\\ {"horse"}\\ {"snake"}\\ {"lizard"}\\ {"parrot"}\\ {"pig"}\\ {"hamster"}\end{array}\right]$ (1)

Go to the last row.

 > $\mathrm{res}:-\mathrm{GotoRow}\left(-1\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"hamster"}$ (3)

Go to the first row.

 > $\mathrm{res}:-\mathrm{GotoRow}\left(1\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"fish"}$ (5)

Go to the second row.

 > $\mathrm{res}:-\mathrm{GotoRow}\left(1,\mathrm{relative}=\mathrm{true}\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"dog"}$ (7)

Go to the second to last row.

 > $\mathrm{res}:-\mathrm{GotoRow}\left(-2\right)$
 ${\mathrm{true}}$ (8)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"pig"}$ (9)

Go to the third to last row (absolute index of 8).

 > $\mathrm{res}:-\mathrm{GotoRow}\left(-1,\mathrm{relative}=\mathrm{true}\right)$
 ${\mathrm{true}}$ (10)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"parrot"}$ (11)

Go to the fourth row (8-4=4).

 > $\mathrm{res}:-\mathrm{GotoRow}\left(-4,\mathrm{relative}=\mathrm{true}\right)$
 ${\mathrm{true}}$ (12)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"rat"}$ (13)

Go to the sixth row (4+2=6).

 > $\mathrm{res}:-\mathrm{GotoRow}\left(2,\mathrm{relative}=\mathrm{true}\right)$
 ${\mathrm{true}}$ (14)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"snake"}$ (15)
 > $\mathrm{res}:-\mathrm{GotoRow}\left(10,\mathrm{relative}=\mathrm{true}\right)$
 ${\mathrm{false}}$ (16)
 > $\mathrm{res}:-\mathrm{GotoRow}\left(20\right)$
 ${\mathrm{false}}$ (17)

 See Also