September 26, 2022, 07:12:17 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Transpose (swap) lines of code

Started by Andy, June 25, 2017, 12:05:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

June 25, 2017, 12:05:23 AM Last Edit: June 25, 2017, 03:30:08 AM by Andy
Well it might just be me doing things the long way round, but whilst writing the PrintLine library I had to transpose lines of code.

This I truly hate doing as it's time consuming, here is an example of what I mean:

I wanted to save the font details so I could read them back later.

oldfnt.lfHeight = fnt.lfHeight
oldfnt.lfWidth = fnt.lfWidth
oldfnt.lfEscapement = fnt.lfEscapement
oldfnt.lfOrientation = fnt.lfOrientation
oldfnt.lfWeight = fnt.lfWeight
oldfnt.lfItalic = fnt.lfItalic
oldfnt.lfUnderline = fnt.lfUnderline
oldfnt.lfStrikeOut = fnt.lfStrikeOut
oldfnt.lfCharSet = fnt.lfCharSet
oldfnt.lfOutPrecision = fnt.lfOutPrecision
oldfnt.lfClipPrecision = fnt.lfClipPrecision
oldfnt.lfQuality = fnt.lfQuality
oldfnt.lfPitchAndFamily = fnt.lfPitchAndFamily
oldfnt.lfFaceName  = fnt.lfFaceName

Then, when I want to reset the font I have to copy/paste and edit the above so it becomes this:

fnt.lfHeight = oldfnt.lfHeight
fnt.lfWidth = oldfnt.lfWidth
fnt.lfEscapement = oldfnt.lfEscapement
fnt.lfOrientation = oldfnt.lfOrientation
fnt.lfWeight = oldfnt.lfWeight
fnt.lfItalic = oldfnt.lfItalic
fnt.lfUnderline = oldfnt.lfUnderline
fnt.lfStrikeOut = oldfnt.lfStrikeOut
fnt.lfCharSet = oldfnt.lfCharSet
fnt.lfOutPrecision = oldfnt.lfOutPrecision
fnt.lfClipPrecision = oldfnt.lfClipPrecision
fnt.lfQuality = oldfnt.lfQuality
fnt.lfPitchAndFamily = oldfnt.lfPitchAndFamily
fnt.lfFaceName = oldfnt.lfFaceName

I have to do this as I might want to set all the fields back EXCEPT say one of them.

fnt.lfHeight = oldfnt.lfHeight
fnt.lfWidth = oldfnt.lfWidth
fnt.lfEscapement = oldfnt.lfEscapement
fnt.lfOrientation = oldfnt.lfOrientation
fnt.lfWeight = 400
fnt.lfItalic = oldfnt.lfItalic
fnt.lfUnderline = oldfnt.lfUnderline
fnt.lfStrikeOut = oldfnt.lfStrikeOut
fnt.lfCharSet = oldfnt.lfCharSet
fnt.lfOutPrecision = oldfnt.lfOutPrecision
fnt.lfClipPrecision = oldfnt.lfClipPrecision
fnt.lfQuality = oldfnt.lfQuality
fnt.lfPitchAndFamily = oldfnt.lfPitchAndFamily
fnt.lfFaceName = oldfnt.lfFaceName

So I have come up with this little transpose program, I use the = sign as a delimiter (in this example), the program then swaps the code either side of the = sign.

You can amend the TransposeThis.iwb file (an example of code needed to be transposed) so the delimiter '=' could be say /, ++, === etc, just enter the correct delimiter before you hit the Transpose Now button.

The above example is just one reason why you may need to transpose many lines of code, so I hope you find this useful?

Anyway, could this be an extra for the IDE (sorry LarryMc lol)?

Attached are the files - please read the 'TransposeThis.iwb' file first.

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.