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 does @trim()

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


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

PostPosted: Thu Apr 14, 2005 10:07 am    Post subject: PARSE does @trim() Reply with quote

PARSE seems to perform a trim() operation on its output. Consider this:

%%item = "1 "@tab()|" 2"
parse "%%p1;%%p2",%%item
info #%%p1##%%p2#

Very unfortunate. That just messed up 110 MB worth of flatfile databases for me Stupid

Dr. 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
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Thu Apr 14, 2005 10:21 am    Post subject: Reply with quote

Yes, it does. It always has. It's the same code used to parse parameters from the command line. Quotes are removed because they can be used to enclose values that contain the separating character. If you need to preserve the quotes then you must parse the string manually.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Dr. Dread
Professional Member
Professional Member


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

PostPosted: Thu Apr 14, 2005 10:35 am    Post subject: Reply with quote

I know about the quotes. That's normal behaviour. What bugs me is that also spaces, tabs etc. are removed
from the start/end of strings.

I'd expect anything but quotes and fieldseps to be returned to my variables.

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
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Thu Apr 14, 2005 11:04 am    Post subject: Reply with quote

No they are not.

This illustrates that leading and training spaces are preserved (and that a field separator may occur within quotes in a data field):

Code:
%D = @chr(34)   Test   @chr(34)|@chr(34) _ab|cd_ @chr(34)
parse "%A;%B",%D
info "%A="%A.@CR()"%B="%B.@CR()

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Dr. Dread
Professional Member
Professional Member


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

PostPosted: Thu Apr 14, 2005 11:13 am    Post subject: Reply with quote

That behaviour requires fields to be quoted. My fields aren't - they are just delimited by a field sep -
which is, by the way, quite normal for db fields that do not hold field seps or any other strange content.

Cannot control database format myself so fields are trimmed by PARSE Crying or Very sad

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
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Thu Apr 14, 2005 12:45 pm    Post subject: Reply with quote

I see.

The problem is really that VDS does not treat spaces as significant. You can write:

Code:
%A = Fred


or

Code:
%A      =             Fred


and the result is exactly the same. It's a basic assumption made by the interpreter. You have to put quotes round things to get the spaces left in.

The PARSE command was really provided for a way to get the results of VDS functions that return several values, such as @FILE or @MOUSEPOS, into several variables. There never are leading or trailing spaces there, so it isn't an issue. It can be used to get the fields out of simple databases, and I have done so myself, but you have to live with its limitations. I've had to write custom code to parse the data where I wanted to keep the quotes round the data, and I guess that's what you'll have to do in your application.

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Dr. Dread
Professional Member
Professional Member


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

PostPosted: Thu Apr 14, 2005 1:00 pm    Post subject: Reply with quote

Right. It would perhaps be nice to know though, so maybe it should be noted in the help file.

I have now added a PARSE function to String.DLL for doing this properly. It goes like this:
@string(PARSE, [input string], [field No. to be extracted], [delim - default is |], [1 = keep quotes in output])
Output will hold any content in the field requested - no manipulations except that double quotes will be
removed unless the function is told to keep'em.

Will be in the next release of String.DLL

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
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Thu Apr 14, 2005 1:06 pm    Post subject: Reply with quote

Sorry you had the problem - but it sounds like another great addition to a great .DLL!
_________________
Joe Floyd
Back to top
View user's profile Send private message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Apr 21, 2005 12:13 am    Post subject: Reply with quote

Hey Dread Smile

When do you think you will release your updated string.dll?
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


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

PostPosted: Thu Apr 21, 2005 8:37 am    Post subject: Reply with quote

Usually I collect a few new things before making a new release. But if you need the PARSE part, let me know
and I could probably make it within a couple of days.

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
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sun Apr 24, 2005 12:41 pm    Post subject: Reply with quote

Yes PLEASE Worship
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


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

PostPosted: Sun Apr 24, 2005 4:17 pm    Post subject: Reply with quote

OK. Version 4.3 is available.

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
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Mon Apr 25, 2005 1:31 pm    Post subject: Reply with quote

You da MAN Worship
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports 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