OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[solved] dumping multiline string row by row to array

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
nysander
General User
General User


Joined: 21 Jun 2008
Posts: 11

PostPosted: Fri Jul 04, 2008 10:14 pm    Post subject: [solved] dumping multiline string row by row to array Reply with quote

Hello, I wanted to as how could I dump unknown length string (char(10) separated)) to array ?

i know function split but I have to define array variable before using it, but i do not know how big this array should be defined. One time it could be 50 lines (char(10) separated) ant the other 200 or more.

is there any function to search for all char(10) to know how many lines are to parse and then redim the array to that number?


Last edited by nysander on Sat Jul 05, 2008 1:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
Mark B
Super User
Super User


Joined: 16 Feb 2007
Posts: 852
Location: Lincolnshire, UK

PostPosted: Sat Jul 05, 2008 12:12 am    Post subject: Reply with quote

I assume that you're reading this in from a database. If that's the case then just redim the array every time that a line of data is read in. Something like:
Code:

dim holder()

while not rs.EOF
    n = ubound(holder) + 1
    redim preserve holder(n)
    holder(n) = rs!field
wend


Mark
_________________
Mark B's Articles
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
nysander
General User
General User


Joined: 21 Jun 2008
Posts: 11

PostPosted: Sat Jul 05, 2008 8:55 am    Post subject: Reply with quote

i got this string from multiline textbox where user pastes some data which i need to parse.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Sat Jul 05, 2008 9:51 am    Post subject: Reply with quote

You don't need to know the dimension of the Split array.
Code:
Option Explicit
Sub Main
Dim s,aray
s = "a b c"
aray = Split(s)
For s = 0 to ubound(aray())
 Print aray(s)
Next
End Sub
Back to top
View user's profile Send private message
nysander
General User
General User


Joined: 21 Jun 2008
Posts: 11

PostPosted: Sat Jul 05, 2008 1:59 pm    Post subject: Reply with quote

thank you very much. it worked as I wanted. my parser is now complete Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group