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 


Parse DSU

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Units
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Wed Feb 04, 2004 1:14 pm    Post subject: Parse DSU Reply with quote

Yes, here is another unit. Smile

This unit is like the PARSE command except it is for an unknown ammount of parse items.

Useage: %t = @parse([string],[Field Sep (Optional)])

Returns a string with each item on a seperate line.

DOWNLOAD

_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Wed Feb 04, 2004 1:50 pm    Post subject: Reply with quote

this is going to be very handy...thanks chris

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Wed Feb 04, 2004 3:21 pm    Post subject: Reply with quote

Sounds interesting! Is it a true record parser like VDS PARSE? I mean, does it acknowledge quoted fields so
you can have field contents holding the field sep character?

"field1";"field2:strg2";"field3;strg3"

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Wed Feb 04, 2004 3:40 pm    Post subject: Reply with quote

No. Sad It do not see the "s. It will still see the fieldsep within the "s and parse that as well. I'll look into that and see if I can get that to work.
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Thu Feb 05, 2004 12:37 pm    Post subject: Reply with quote

Hey Dread. I can make a true record with this. I'll work on it and post it ASAP. Very Happy
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Thu Feb 05, 2004 1:10 pm    Post subject: Reply with quote

Ok, @parse() has been updated. It is now a true parser.

Code:

%s = @chr(34)test;test@chr(34);test;test
%t = @parse(%s,Wink
# This will return
#
# test;test
# test
# test


DOWNLOAD

_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 05, 2004 4:02 pm    Post subject: Reply with quote

Great. Took it for a quick spin...

Did you consider that when parsing flat-file db-records, there will often be empty fields? Wink

"field1";"";"field3"
or
;;"field1";;"field3"


Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Thu Feb 05, 2004 4:07 pm    Post subject: Reply with quote

Man, pickey pickey. Smile I did not. Did you gice that a try? I will not have time to look at it right now. Give it a try and post what you did and what it returns.

Thanks

_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 05, 2004 7:59 pm    Post subject: Reply with quote

Yeah. I did try it - actually that's why I asked coz when parsing records you're gonna run into this type of
record sooner or later.

I do lots of flat-file db parsing in VDS so I'm acquainted with it. I think I may have a similar routine lying
around somewhere. I'll see if I can dig it up.

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 05, 2004 8:12 pm    Post subject: Reply with quote

Right. I found it...

Code:

%%fieldsep = ";"
option fieldsep,%%fieldsep

%%string = @CHR(34)@CHR(34);@CHR(34)1@CHR(34);2;@CHR(34)3;A@CHR(34);@CHR(34)4@CHR(34);;

list create,1

repeat
 parse "%%item",%%string
 %%itemlen = @len(%%item)
 list add,1,%%item
 
REM Remove quote if string starts with it
 if @equal(@substr(%%string,1),@CHR(34))
   %%string = @strdel(%%string,1,)
 end
 
REM Remove already extracted field content
 %%string = @strdel(%%string,1,%%itemlen)
 
REM Remove quote if current field was enclosed
 if @equal(@substr(%%string,1),@CHR(34))
   %%string = @strdel(%%string,1,)
 end

REM Now remove fieldsep
 if @equal(@substr(%%string,1),%%fieldsep)
   %%string = @strdel(%%string,1,)
 end
until @null(%%string)

info @text(1)
list close,1


Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Thu Feb 05, 2004 8:16 pm    Post subject: Reply with quote

Nice. I'll update the DSU adding your code. Thanks.
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Thu Feb 05, 2004 8:27 pm    Post subject: Reply with quote

It has been updated. Thanks again.
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 05, 2004 10:04 pm    Post subject: Reply with quote

Cool Cool

Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Units 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