yep mv target selection control and row formations

I'm using yanfly row formation and target selection.
I have made a spear that can only be used in the first row and can target the first or second enemy row.
I'm wondering if there is a way to make the spear change its attack selection based on which row it's in,
such as above plus if in row 2 can only target enemy row 1.

---------
<only row:1>
<select conditions>
row 2 max
</select conditions>
-----------
<only row 2>
<select conditions>
front row only
</select conditions>
--------------

is there a way to get one weapon to work with both options?

I've tried something like this

<custom select condition>
if battler.row(1) {max row 2}
else
if battler.row(2) {front row only}
else
{row only 1,2}
</custom select condition>

but I just get errors...
OK so I'm using yep-weapons unleashed to give my different weapon types their own attacks.
So I made a spear, and a spear attack skill, using weapons unleashed i linked them.

this note tag allows the skill to only be used in row 2 and only target rows one and two.
---------
<only row:1>
<select conditions>
row 2 max
</select conditions>
-----------

this note tag allows the skill to only be used in the second row and only target the front row.
-----------
<only row 2>
<select conditions>
front row only
</select conditions>
--------------

I cannot figure out how to get the skill to change its targeting options based on the battlers row.

<custom row condition>
if battler.row() = 1 {max row 2}
else
if battler.row() = 2 {front row only}
else
{row only 1,2}
</custom row condition>

I've tried the above note tag but it doesn't quite work.
the skill can be used from anywhere and can only target front row.

------------------------------------------
{row only: 1,2;}
<Custom Select Condition>
if (battler.row() === 1) {row 2 max;}
else {front row only;}
</Custom Select Condition>
------------------------------------------------
this note tag in my reach skill causes an error,
syntax error: unexpected number.
Hi, guys... It seems that I want to do exactly the same thing as what is stated over there... Could anyone help me to figure the code since I'm not proficient in JS? My game uses 2 rows only.

Original thread: https://forums.rpgmakerweb.com/threads/yep-mv-target-selection-control-and-row-formations.89273/