In older versions of X# the Ctrl+K Ctrl+D Edit/Advanced option in VS would nicely format your X# code, just as it does in C#. Microsoft broke that with some changes but I see in the release notes that it is fixed again in X# 2.21.
I have tried it out and it does do things again but not perhaps what we need, so I have some examples.
I tried it on this code which was mostly created by the default X# WinForms project I used to make a baby app to fiddle with CRC calculations
Code: Select all
USING System
USING System.Collections.Generic
USING System.ComponentModel
USING System.Data
USING System.Drawing
USING System.Linq
USING System.Text
USING System.Threading.Tasks
USING System.Windows.Forms
BEGIN NAMESPACE test2
PUBLIC PARTIAL CLASS Form1 ;
INHERIT System.Windows.Forms.Form
PUBLIC CONSTRUCTOR() STRICT//Form1
InitializeComponent()
RETURN
END CONSTRUCTOR
PRIVATE METHOD btnCalc_Click(sender AS System.Object, e AS System.EventArgs) AS VOID STRICT
LOCAL cDecCRC AS STRING
LOCAL cHexCRC AS STRING
cDecCRC := CalcCRCMess(txtPacket:Text)
cHexCRC := Convert.ToString(Convert.ToInt32(cDecCRC), 16)
lblCRC:Text := "Dec " + cDecCRC + " Hex " + cHexCRC
RETURN
END METHOD
END CLASS
END NAMESPACE
Code: Select all
USING System
USING System.Collections.Generic
USING System.ComponentModel
USING System.Data
USING System.Drawing
USING System.Linq
USING System.Text
USING System.Threading.Tasks
USING System.Windows.Forms
BEGIN NAMESPACE test2
PUBLIC PARTIAL CLASS Form1 ;
INHERIT System.Windows.Forms.Form
PUBLIC CONSTRUCTOR() STRICT//Form1
InitializeComponent()
RETURN
END CONSTRUCTOR
PRIVATE METHOD btnCalc_Click(sender AS System.Object, e AS System.EventArgs) AS VOID STRICT
LOCAL cDecCRC AS STRING
LOCAL cHexCRC AS STRING
cDecCRC := CalcCRCMess(txtPacket:Text)
cHexCRC := Convert.ToString(Convert.ToInt32(cDecCRC), 16)
lblCRC:Text := "Dec " + cDecCRC + " Hex " + cHexCRC
RETURN
END METHOD
END CLASS
END NAMESPACE
A more worrying one is this code fragment.
Code: Select all
IF dwTotal > 0
FOR dwN := 1 UPTO dwTotal
cFile := aFileList[dwN,1]
SELF:oDCStatusSLE:TextValue := "Processing " + cFile + " "
ApplicationExec(EXECWHILEEVENT)
//PrintStr("process file", cFile)
SELF:ProcessXML(cFile)
NEXT
ENDIF
SELF:oDCStatusSLE:TextValue := "Waiting "
SELF:oDCTimerTxt:Start()
RETURN NIL
Code: Select all
IF dwTotal > 0
FOR dwN := 1 UPTO dwTotal
cFile := aFileList[dwN,1]
SELF:oDCStatusSLE:TextValue := "Processing " + cFile + " "
ApplicationExec(EXECWHILEEVENT)
//PrintStr("process file", cFile)
SELF:ProcessXML(cFile)
NEXT
ENDIF
SELF:oDCStatusSLE:TextValue := "Waiting "
SELF:oDCTimerTxt:Start()
RETURN NIL
I thought I should warn people to not use this editing option unless they like left justified code. I don't know where the rules of indenting get defined for this but perhaps Robert knows. I often use these options in C# when I move code about to get things tidy again. It would be good if it worked in X# too.
Cheers,
John Bonnett

