Entry
TSE: Menu: Character: Hotkey: How to get all the hotkey characters in menu block in a sorted string?
Nov 7th, 2006 12:55
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 07 November 2020 - 08:56 pm -------------------
TSE: Menu: Character: Hotkey: How to get all the hotkey characters in
menu block in a sorted string?
---
You search for all the menu lines in the given block, and extract the
first character after the '&' in each of that menu lines and put
these in a string.
Then you sort this single characters in the resulting string.
===
--- cut here: begin --------------------------------------------------
// library: string: get: sort: character: insert [kn, ho, tu, 07-11-
2006 19:38:47]
STRING PROC FNStringGetSortCharacterInsertS( STRING characterS, STRING
inS )
INTEGER I = 0
INTEGER insertB = FALSE
INTEGER lengthI = 0
STRING cS[255] = ""
STRING s[255] = inS
I = 1 - 1
REPEAT
I = I + 1
lengthI = Length( s )
insertB = FALSE
cS = SubStr( s, I, 1 )
IF ( characterS <= cS )
s = SubStr( s, 1, I - 1 ) + characterS + SubStr( s, I, lengthI - I
+ 1 )
insertB = TRUE
ENDIF
UNTIL ( insertB ) OR ( I >= lengthI )
IF NOT insertB
s = s + characterS
ENDIF
RETURN( s )
END
// library: string: get: sort: character: all [kn, ho, tu, 07-11-2020
21:43:36]
STRING PROC FNStringGetSortCharacterAllS( STRING inS )
STRING s[255] = ""
STRING characterS[255] = ""
INTEGER I = 0
FOR I = 1 TO Length( inS )
characterS = SubStr( inS, I, 1 )
s = FNStringGetSortCharacterInsertS( characterS, s )
ENDFOR
RETURN( s )
END
// library: string: get: menu: block: character: hotkey: all
(filenamemacro=getsthal.s) [kn, ho, tu, 07-11-2020 20:44:45]
STRING PROC FNStringGetMenuBlockCharacterHotkeyAllS()
INTEGER downB = TRUE
STRING s[255] = ""
STRING menuLetterAllS[255] = ""
STRING menuLetterS[255] = ""
INTEGER foundI = 0
IF NOT IsBlockMarked()
Warn( "please mark a block" )
RETURN( "" )
ENDIF
PushPosition()
GotoBlockBegin()
WHILE IsCursorInBlock() AND downB
IF LFind( '^{[ ]@}{["].*["]}', "x" )
s = GetFoundText( 2 )
foundI = Pos( "&", s )
IF ( foundI <> 0 )
menuLetterS = SubStr( s, foundI + 1, 1 )
menuLetterAllS = menuLetterAllS + menuLetterS
ENDIF
ENDIF
downB = Down()
ENDWHILE
PopPosition()
RETURN( menuLetterAllS )
END
STRING PROC FNStringGetSortMenuBlockCharacterHotkeyAllS()
STRING s[255] = ""
s = FNStringGetMenuBlockCharacterHotkeyAllS()
s = FNStringGetSortCharacterAllS( s )
RETURN( s )
END
PROC Main()
Message( FNStringGetSortMenuBlockCharacterHotkeyAllS() ) // gives
e.g. "ABCDFGH"
END
<F12> Main()
--- cut here: end ----------------------------------------------------
===
Internet: see also:
---
TSE: Menu: Character: Hotkey: Link: Overview: Can you give an overview
of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/42905/fid/1571
----------------------------------------------------------------------