How can I get this to return an entire array without the (..)?
arr = for i = 1 to 30 collect i
arr
dont want -
#(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...)
I want -
#(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,21, 22, 23, 24, 25, 26, 27, 28, 29, 30)
By
Comments (5)
Comment policy
StringArrayWithNoSpaceBetweenTwoItems
With this fn you can skip substring method
I'm using this to put array values to TextBox,
but without "#(" and ")".
a = for i in 1 to 30 collect i
fn stringArrNoSpace arr =
(
local res = "#("
for i = 1 to arr.count do
(
res += arr[i] as string ; if i < arr.count do res += ","
) ; res += ")"
)
stringArrNoSpace a
SOLUTION!
a = for i = 1 to 30 collect i
b = "#("
for n in a do b += (n as string) + ", "
b = substring b 1 (b.count - 2) + ")"
more than expected
This is what I have so far.
Doesn't work if there is only 1 item in the array.
donuts = for i = 1 to 60 by 2 collect i
--donuts = for i = 1 to 1 collect i
txt = "insert your texasdsadt"
file = (createFile @"C://Users/Crabs User/Desktop/trash/copyto/testing5.txt")
format "%" "#(" to:file
for i = 1 to donuts.count do
(
x = donuts[i]
if x != 1 AND x != donuts.count then
(
format ",%" x to:file
)else(
format "%" x to:file
)
)
format "%" ")" to:file
close file
I need it to be put into a variable though. Not just printed....??
Use the PrintAllElements
Use the