Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
133
Task/Align-columns/TSE-SAL/align-columns.tse
Normal file
133
Task/Align-columns/TSE-SAL/align-columns.tse
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
INTEGER PROC FNBlockChangeColumnAlignLeftB( INTEGER columnTotalI, INTEGER spaceTotalI, INTEGER buffer1I )
|
||||
INTEGER B = FALSE
|
||||
INTEGER downB = TRUE
|
||||
INTEGER minI = 1
|
||||
INTEGER I = 0
|
||||
INTEGER J = 0
|
||||
INTEGER K = 0
|
||||
INTEGER L = 0
|
||||
INTEGER buffer2I = 0
|
||||
STRING s[255] = ""
|
||||
INTEGER wordRightB = FALSE
|
||||
STRING s1[255] = Query( WordSet )
|
||||
IF ( NOT ( IsBlockInCurrFile() ) ) Warn( "Please mark a block" ) B = FALSE RETURN( B ) ENDIF // return from the current procedure if no block is marked
|
||||
Set( BREAK, ON )
|
||||
PushPosition()
|
||||
PushBlock()
|
||||
Set( WordSet, ChrSet( "a-zA-Z0-9_,." ) )
|
||||
PushPosition()
|
||||
buffer2I = CreateTempBuffer()
|
||||
PopPosition()
|
||||
PushPosition()
|
||||
PushBlock()
|
||||
DO 100 TIMES
|
||||
AddLine( "", buffer2I )
|
||||
ENDDO
|
||||
PopBlock()
|
||||
PopPosition()
|
||||
GotoBlockBegin()
|
||||
I = minI - 1
|
||||
WHILE ( ( IsCursorInBlock() ) AND ( downB ) )
|
||||
IF NOT LFind( "^$", "cgx" )
|
||||
BegLine()
|
||||
REPEAT
|
||||
s = GetWord()
|
||||
IF NOT ( s == "" )
|
||||
s = Trim( s )
|
||||
I = I + 1
|
||||
IF ( I > columnTotalI )
|
||||
I = minI
|
||||
ENDIF
|
||||
J = Length( s )
|
||||
PushPosition()
|
||||
PushBlock()
|
||||
GotoBufferId( buffer2I )
|
||||
GotoLine( I )
|
||||
//
|
||||
IF ( CurrLineLen() == 0 )
|
||||
BegLine()
|
||||
InsertText( Format( Str( J ), " " ), _INSERT_ )
|
||||
ELSE
|
||||
K = Val( Trim( GetText( 1, MAXSTRINGLEN ) ) )
|
||||
IF ( J > K )
|
||||
BegLine()
|
||||
DelToEol()
|
||||
BegLine()
|
||||
InsertText( Str( J ), _INSERT_ )
|
||||
ENDIF
|
||||
ENDIF
|
||||
PopBlock()
|
||||
PopPosition()
|
||||
wordRightB = WordRight()
|
||||
ENDIF
|
||||
UNTIL ( s == "" ) OR ( NOT wordRightB )
|
||||
ENDIF
|
||||
downB = Down()
|
||||
ENDWHILE
|
||||
GotoBlockBegin()
|
||||
I = minI - 1
|
||||
L = 1
|
||||
K = 1
|
||||
WHILE ( ( IsCursorInBlock() ) AND ( downB ) )
|
||||
IF NOT LFind( "^$", "cgx" )
|
||||
BegLine()
|
||||
REPEAT
|
||||
B = FALSE
|
||||
s = GetWord()
|
||||
IF NOT ( s == "" )
|
||||
s = Trim( s )
|
||||
I = I + 1
|
||||
IF ( I > columnTotalI )
|
||||
I = minI
|
||||
K = 1
|
||||
L = L + 1
|
||||
ENDIF
|
||||
//
|
||||
PushPosition()
|
||||
PushBlock()
|
||||
GotoBufferId( buffer2I )
|
||||
GotoLine( I )
|
||||
J = Val( Trim( GetText( 1, MAXSTRINGLEN ) ) )
|
||||
PopPosition()
|
||||
PopBlock()
|
||||
PushPosition()
|
||||
PushBlock()
|
||||
GotoBufferId( buffer1I )
|
||||
GotoLine( L )
|
||||
GotoColumn( K )
|
||||
InsertText( s, _INSERT_ )
|
||||
K = K + J + spaceTotalI
|
||||
PopBlock()
|
||||
PopPosition()
|
||||
wordRightB = WordRight()
|
||||
ENDIF
|
||||
UNTIL ( s == "" ) OR ( NOT wordRightB )
|
||||
ENDIF
|
||||
AddLine( "", buffer1I )
|
||||
downB = Down()
|
||||
ENDWHILE
|
||||
OneWindow()
|
||||
VWindow()
|
||||
GotoWindow( 1 )
|
||||
GotoBufferId( buffer2I )
|
||||
GotoWindow( 2 )
|
||||
GotoBufferId( buffer1I )
|
||||
B = TRUE
|
||||
Set( WordSet, s1 )
|
||||
PopPosition()
|
||||
PopBlock()
|
||||
RETURN( B )
|
||||
END
|
||||
//
|
||||
PROC Main()
|
||||
STRING s1[255] = "12" // change this
|
||||
STRING s2[255] = "2" // change this
|
||||
INTEGER bufferI = 0
|
||||
PushPosition()
|
||||
bufferI = CreateTempBuffer()
|
||||
PopPosition()
|
||||
IF ( NOT ( Ask( "block: change: column: align: left: columnTotalI = ", s1, _EDIT_HISTORY_ ) ) AND ( Length( s1 ) > 0 ) ) RETURN() ENDIF
|
||||
IF ( NOT ( Ask( "block: change: column: align: left: spaceTotalI = ", s2, _EDIT_HISTORY_ ) ) AND ( Length( s2 ) > 0 ) ) RETURN() ENDIF
|
||||
Message( FNBlockChangeColumnAlignLeftB( Val( s1 ), Val( s2 ), bufferI ) ) // gives e.g. TRUE
|
||||
GotoBufferId( bufferI )
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue