GLL Example: Convert Characters

Convert characters to uppercase using Gfa_Insert.

Convert one or more characters on one or more lines to uppercase. When there is no selection the character on the right of the cursor is selected and changed to uppercase. Since Gfa_Insert is used to replace the selection, the conversion can cross line boundaries. Gfa_Right and Gfa_Insert are both actions that are stored in the Undo buffer, which can take 64 actions. As such, Gfa_Ex_V can only be undone 32 times.

 

Sub Gfa_Ex_V

Local Int ln, c

If Gfa_IsSelection

Gfa_Insert Upper(Gfa_Selection)

Else

ln = Gfa_Line : c = Gfa_Col

Gfa_Right

Gfa_SelLine = ln : Gfa_SelCol = c

Gfa_Insert Upper(Gfa_Selection)

EndIf

EndSub

The difference with the previous example is that when no selection is available there is no temporary selection set as well. This reduces the number of undo actions.

 

Sub Gfa_App_U

If Gfa_IsSelection

Gfa_Insert Upper(Gfa_Selection)

Else

Gfa_Right

If Gfa_Col

Gfa_Replace Upper(Mid(Gfa_Text, Gfa_Col - 1, 1))

EndIf

EndIf

EndSub

{Created by Sjouke Hamstra; Last updated: 08/10/2014 by James Gaite}