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 


Parsing problems
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
ShinobiSoft
Professional Member
Professional Member


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

PostPosted: Sat Dec 14, 2002 11:44 pm    Post subject: Reply with quote

Instead of parsing the string out, why not replace the fieldsep character with a carriage return @cr() and then assign the string to a string list. Each part of the original string would then be contained on a seperate line within the string list.

Here's an example:

Code:

  %%fieldsep = @chr(44)
  %%sourceString = Line 1,Line 2,Line 3,Line 4
  repeat
    %p = @pos(%%fieldsep,%%sourceString)
    if @greater(%p,0)
      %%sourceString = @strdel(%%sourceString,%p)
      %%sourceString = @strins(%%sourceString,%p,@cr())
    end
  until @zero(%p)
 
  if @not(@null(%%sourceString))
    list create,1
    list assign,1,%%sourceString
    info @text(1)
    list close,1
  end



Bill
ShinobiSoft

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."


Last edited by ShinobiSoft on Sun Dec 15, 2002 12:41 am; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sat Dec 14, 2002 11:47 pm    Post subject: Reply with quote

I must say, that's a brilliant approach! Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 15, 2002 12:26 am    Post subject: Reply with quote

Uh... have ya actually tried that example?
_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
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: Sun Dec 15, 2002 12:30 am    Post subject: Reply with quote

Not in that exact format. Instead of the %%fieldsep variable, I usually hard code the fieldsep character.

Code:

  %p = @pos(",",%%sourceString)
  .
  .
  .



Bill

_________________
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
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 15, 2002 12:39 am    Post subject: Reply with quote

My point is - the example doesn't work. Unless you're
trying to lose the last three fields... Confused

BTW, @chr(34) is a quote, but when ya replace it with
@chr(44) (a comma), it still doesn't work.

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sun Dec 15, 2002 12:44 am    Post subject: Reply with quote

Sorry Mac, I hadn't tried it yet, I wasn't talking about the example, but about the approach.

The error is the line were %%sourceString is assigned to. It should say:

Code:

  %%sourceString = "Line 1,Line 2,Line 3,Line 4"



So the double quotes were missing.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ShinobiSoft
Professional Member
Professional Member


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

PostPosted: Sun Dec 15, 2002 12:45 am    Post subject: Reply with quote

Thanks for pointing out the typeo @chr(34) should have been @chr(44). I've edited my post for this correction.

What I don't understand is why it doen't work for you. It works fine for me. I wouldn't have suggested it if it didn't work! Confused Confused

_________________
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
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 15, 2002 1:03 am    Post subject: Reply with quote

OK, it works with the quotes. Wink

But is there a reason ya rather tie up a list than
loop thru and add @chr(34) to the string? Ya could
PARSE it into vars (with meaningful names) then...

Also, any vars used in your example must still be
excluded from the outside quotes...

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
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: Sun Dec 15, 2002 1:11 am    Post subject: Reply with quote

I was just offering an alternative method to parsing information. Smile
_________________
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
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Dec 15, 2002 1:11 am    Post subject: Reply with quote

__________________________________________________________________________________________________________________________
It would probably be most simple to just use the following instead of re-inventing the wheel. Wink

Code:
%%string = @chr(34)Data 1  @chr(34)|@chr(34)    Data 2@chr(34)|@chr(34) Data 3 @chr(34)| Data 4
parse "%%data1;%%data2;%%data3;%%data4",%%string
info %%data1;%%data2;%%data3;%%data4

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sun Dec 15, 2002 2:06 am    Post subject: Reply with quote

FreezingFire wrote:
__________________________________________________________________________________________________________________________
It would probably be most simple to just use the following instead of re-inventing the wheel. Wink

Code:
%%string = @chr(34)Data 1  @chr(34)|@chr(34)    Data 2@chr(34)|@chr(34) Data 3 @chr(34)| Data 4
parse "%%data1;%%data2;%%data3;%%data4",%%string
info %%data1;%%data2;%%data3;%%data4


I disagree, as this method could only be used after the text is parsed. What is the use
of parsing if the text is already parsed?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 15, 2002 2:15 am    Post subject: Reply with quote

Didn't he meant add @chr(34) when ya add the
separators to begin with?

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sun Dec 15, 2002 4:11 am    Post subject: Reply with quote

Yes but the whole point is that you don't always create the files that you want to read,
so you'll just have to stick with the format that was decided by the file's original author/software.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 15, 2002 4:25 am    Post subject: Reply with quote

Quotes are in a lot (if not most) field separated files
anyway. If ya make PARSE include everything between
separators you'd have to have a routine to get rid of
'em on those files.

And ya could loop thru a list (loaded file) and add
@chr(34) just as easy as removing quotes when ya
didn't want 'em...

Or is there a method to have it both ways?

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Dec 15, 2002 8:54 am    Post subject: Reply with quote

Mac wrote:
Show 'em on separate lines and it makes more sense
Garrett. Each parsed item is still trimmed because it
doesn't see the quotes... Wink


Mac, for me it retained the spaces when I ran that code. At least it did on
VDS 4.x for me.

-Garrett
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 -> Bug Reports All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 4 of 5

 
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