View previous topic :: View next topic |
Author |
Message |
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Apr 14, 2005 10:07 am Post subject: PARSE does @trim() |
|
|
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
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Apr 14, 2005 10:21 am Post subject: |
|
|
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 |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Apr 14, 2005 10:35 am Post subject: |
|
|
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 |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Apr 14, 2005 11:04 am Post subject: |
|
|
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 |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Apr 14, 2005 11:13 am Post subject: |
|
|
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
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Apr 14, 2005 12:45 pm Post subject: |
|
|
I see.
The problem is really that VDS does not treat spaces as significant. You can write:
or
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 |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Apr 14, 2005 1:00 pm Post subject: |
|
|
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 |
|
|
jwfv Valued Contributor
Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Thu Apr 14, 2005 1:06 pm Post subject: |
|
|
Sorry you had the problem - but it sounds like another great addition to a great .DLL! _________________ Joe Floyd |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Apr 21, 2005 12:13 am Post subject: |
|
|
Hey Dread
When do you think you will release your updated string.dll? |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Apr 21, 2005 8:37 am Post subject: |
|
|
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 |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Sun Apr 24, 2005 12:41 pm Post subject: |
|
|
Yes PLEASE |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Apr 24, 2005 4:17 pm Post subject: |
|
|
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 |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Apr 25, 2005 1:31 pm Post subject: |
|
|
You da MAN |
|
Back to top |
|
|
|