Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] store text in array of lines

I'd like to store some html into an array of lines, but I can't find anything to do that.

Is there such a function?

Alternatively, I thought I could loop through the text line by line and copy it to an array element.

Macro Macro2215
Copy      Help
str s=

ARRAY(str) a=s
Thanks for the quick response.

It seems that I have to manually input the lines.

Here's some sample text that I would grab from an html source. I'm trying to put each of the four lines into an array element automatically, if possible..

<link href="assets/css/lib/bootstrap.css" rel="stylesheet">
<link href="assets/css/lib/bootstrap-responsive.css" rel="stylesheet">
<link href="assets/css/ur-extension.css" rel="stylesheet">
<link href="assets/css/ur.css" rel="stylesheet">

Hi Gintaras,

I haven't heard back so I'm following up. I would really appreciate your help. Thanks.
If my code does not do what you need, please explain more, and give some your code to help to understand better.
My goal was to store a bunch of code as an array of lines - each array element would hold a line of code.

I accidentally found a very useful function to solve this problem Big Grin . See below

Copy      Help
;select all
'Ca         ;;highlight all

str htmltextboxsourcecode



ARRAY(str) arrayoflines
int i = 0

For each line:
str s
str lines = htmltextboxsourcecode


foreach s lines
    if(!s.len) continue
    arrayoflines[i] = s    
    out arrayoflines[i]
    i + 1 ;;increment count by 1
I think my code does the same.
Your code does work. It looked to me that I had to declare each line manually in your example. Thanks for the elegant solution.

Forum Jump:

Users browsing this thread: 1 Guest(s)