forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Replacing white spaces with newlines

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Capinha
Newbie


Joined: 19 Oct 2006
Posts: 13
Location: Portugal

PostPosted: Tue Mar 25, 2008 10:08 pm    Post subject: Replacing white spaces with newlines Reply with quote

Hello there,

I have several large sized number matrix with columns separated by whitespace, and I'm trying to transform the whitespace in a carriage return, so that all values converge in one column.

Something like:

from this:
123 122 133 122
122 111 111 222
...

to this:
123
122
133
122
122
111
111
222
...

I've tried to use this expression using string.dll extension

%b = @string(RegxRepInFile,c:\file.txt,c:\output.txtt," ",@cr(),)

and also:

%b = @string(RegxRepInFile,c:\file.txt,c:\output.txtt," ",(\r),)

but the first returns a rectangular symbol in place of the whitespace and the other just inserts the "r" character...

The optional use of repeat or if sentences instead revealed to be very very time consuming...

any sugestions?


Cheers

César

_________________
César Capinha
Back to top
View user's profile Send private message Send e-mail
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Wed Mar 26, 2008 4:04 am    Post subject: Reply with quote

Try this::
Code:


  REM The following code assumes that string list #1 contains the contents
  REM of the file to transform the data for. I am also assuming that we
  REM are replacing @chr(32)<space> with a line feed @chr(13)@chr(10)

  %%text  = @text(1)
  repeat
    %p = @pos(" ",%%text)
    if @greater(%p,0)
      %%text = @strdel(%%text,%p)
      %%text = @strins(%%text,%p,@chr(13)@chr(10))
    end
  until @zero(%p)
 
  REM Now put the modified file contents into string list #1
  list assign,1,%%text


_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
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
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group