Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Empty Line at the end of ARRAY.
#1
Function Function45
Code:
Copy      Help
out
;ARRAYS add an empty line to the end when outputting them.  This is undesireable in some cases and cannot figure out how to get rid of it.

out "----Example 1----"
str Multiline_Text=
;Line 1
;Line 2
;Line 3
;Line 4
;Line 5
ARRAY(str) Array1=Multiline_Text
out Array1
out "There shouldn't be an empty line above this."
out "----Example 2----"
ARRAY(str) Array2
int i=1

rep 5
,Array2[]=_s.from("Line " i)
,i+1
out Array2
out "There shouldn't be an empty line above this."

out "----A string solution----"
Multiline_Text=Array1
_i=Multiline_Text.len
_s.left(Multiline_Text _i-2)
out _s
out "There is not an empty line above this."

;Outputs:
;----Example 1----
;Line 1
;Line 2
;Line 3
;Line 4
;Line 5
;
;There shouldn't be an empty line above this.
;----Example 2----
;Line 1
;Line 2
;Line 3
;Line 4
;Line 5
;
;There shouldn't be an empty line above this.
;----A string solution----
;Line 1
;Line 2
;Line 3
;Line 4
;Line 5
;There is not an empty line above this.
#2
Function outARRAY
Code:
Copy      Help
;/
function ARRAY(str)&a

str s=a
if(s.len) s.fix(s.len-2)
out s
#3
Thanks Gint.

Why does ARRAY do this in the first place? Any way to fix that, that would probably take a ton of work...maybe someday Wink

Thanks,
Jimmy Vig
#4
I also often use these.

Function outw
Code:
Copy      Help
;/
function hwnd [$prefix]

;Displays window handle, class and text (first line) in QM output.


if(!hwnd) out 0; ret
str s.getwinclass(hwnd); err
str ss.getwintext(hwnd); err
ss.trim; ss.getl(ss 0)
out "%s%i %s ''%s''" prefix hwnd s ss

Function outRECT
Code:
Copy      Help
;/
function RECT&r

out "L=%i T=%i R=%i B=%i   W=%i H=%i" r.left r.top r.right r.bottom r.right-r.left r.bottom-r.top

Function outref
Code:
Copy      Help
;/
function i

;Displays COM object's reference count.


IUnknown u
memcpy &u &i 4
u.AddRef; out u.Release
memset &u 0 4
#5
Thanks Gintaras!

I was able to work up exactly what I need from what you've posted. Usually I'm setting text to a file or doing something with it other than just outputting. Now I have a better way to get text from an ARRAY to a string without that annoying little empty line!

Member function str.FromArray
Code:
Copy      Help
function ARRAY(str)&a

;;Example
;ARRAY(str) a
;int i=1
;rep 10
,;a[]=_s.from("Line " i)
,;i+1
;_s.FromArray(a)
;
;out _s

str s=a
if(s.len)
,s.fix(s.len-2)
this=s


Forum Jump:


Users browsing this thread: 1 Guest(s)