Code: Select all
line := trim(line," `t`r`n")
Code: Select all
line := trim(line," `t`r`n")
Code: Select all
lineOld := " Hallo `r`n "
line := trim(lineOld," `t`r`n")
MsgBox,% "lineOld:`n >" lineOld "<`nline:`n >" line "<"
Code: Select all
word := line
word := trim(word,"`r`n")
line := ""
loop, parse, word
{
line .= A_loopfield
if instr(A_loopfield,".")
break
}
Code: Select all
;- Problem with unwanted blank line.
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=89690
;- example remove last line's EOL (ascii 09-TAB 13-CR and 10-LF ) ( and other empty lines )
autotrim,on ;- this is default
f1=%a_scriptdir%\test1.txt
f2=%a_scriptdir%\test2.txt
ifexist,%f2%
filedelete,%f2%
transform,s,chr,34
e1=
(ltrim join`r`n
Use this to draw straight lines and to measure lengths.
Use this to prop up books.
Use this to keep your stationery items tidy.
)
ifnotexist,%f1%
fileappend,%e1%,%f1%,utf-8
fileread,aa,%f1%
loop,parse,aa,`n,`r
{
x:=a_loopfield
if (x="")
continue
x=%x% ;- remove leading spaces
e2 .= s . x . s . "`r`n"
}
;e3:= RTrim(e2, "`r`n")
e3:= Trim(e2," `t`r`n") ;- Rohwedder's example
fileappend,%e3%,%f2%,utf-8
try
run,%f2%
exitapp
Code: Select all
Guicontrol, Test:hide, SC
;use a dummy gui to calculate whether the new text fits on one line (if so center it
;or two or more lines (if so wrap it left)
Gui, w:new, -dpiscale
Gui, Font, s%SF% bold, arial ;SF is the size of the font that will fit the longest line of text in the space available.
Gui, Font, s%SF% bold, Comic Sans MF
Gui, Font, s%SF% bold, aakidprint
Gui, w:add, text, vs w%wid%, %line% ;wid is the width available for the text.
Guicontrolget, s, w:pos
Guicontrol, Test:, SC, %line%
Guicontrolget, SC, Test:pos
if(sh > TP) ;TP height of single line of text with the font
Guicontrol, Test: +left, SC
else
Guicontrol, Test: +center, SC
newy := (_H - sH)/2 ;_H is the height of my monitor
Guicontrol, Test:move, SC, % "y" newy "h" sh ; the aim is to center the text.
Guicontrol, Test:show, SC
Users browsing this forum: Google [Bot], Rohwedder and 238 guests