Unfortunately the style is part of the spatial object and to change this, users need to update the object and then update the record with the new object.
This is considered a complex process and so is not written to the MapBasic window.
Users need to perform this action for each record in the table in the form of a loop:
Include "MAPBASIC.DEF"
Declare Sub Main
Sub Main
Dim oObj As Object
Dim iRow As Integer
Dim penNew as Pen
penNew = MakePen(2, 3, RED)
Fetch First From Selection
Do Until EOT(Selection)
oObj = Selection.OBJ
iRow = Selection.ROWID
Alter Object oObj
Info OBJ_INFO_PEN, penNew
Update Selection
Set OBJ = oObj
Where ROWID = iRow
Fetch Next From Selection
Loop
End Sub Main
The above example will achieve this goal however users may suffer from performance issues depending on the size of the selection, it would be much quicker using a function rather than performing the fetch inside a loop, please see the example below. Just remember to only update records that do have a line style.
Include "MAPBASIC.DEF"
Declare Sub Main
Declare Function STLAlterPen(ByVal oObj As Object, ByVal penNew As Pen) As Object
Sub Main
Update Selection
Set OBJ = STLAlterPen(OBJ, CurrentPen())
End Sub
Function STLAlterPen(ByVal oObj As Object, ByVal penNew As Pen) As Object
OnError GoTo ErrorOccured
penNew = MakePen(2, 3, RED)
STLAlterPen = oObj
Alter Object oObj
Info OBJ_INFO_PEN, penNew
STLAlterPen = oObj
Exit Function
'-------------------------
ErrorOccured:
Print Err() + " " + Error$() + " STLAlterPen"
End Function