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

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.

Thanks.
#2
Macro Macro2215
Code:
Copy      Help
str s=
;one
;two
;three

ARRAY(str) a=s
#3
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">

Thanks
#4
Hi Gintaras,

I haven't heard back so I'm following up. I would really appreciate your help. Thanks.
#5
If my code does not do what you need, please explain more, and give some your code to help to understand better.
#6
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

Code:
Copy      Help
;select all
'Ca         ;;highlight all

str htmltextboxsourcecode

htmltextboxsourcecode.getsel

clo

ARRAY(str) arrayoflines
int i = 0

For each line:
str s
str lines = htmltextboxsourcecode

arrayoflines.create(numlines(lines))

foreach s lines
    if(!s.len) continue
    arrayoflines[i] = s    
    out arrayoflines[i]
    i + 1 ;;increment count by 1
#7
I think my code does the same.
#8
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)