View previous topic :: View next topic |
Author |
Message |
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Nov 11, 2003 8:07 pm Post subject: A function to strip the path off of a path & filename |
|
|
A function to strip the path off of a path & filename would eliminate a lot of
unnecessary coding, for example the usual code I use for this is:
Code: | if @ext(%F)
%%name = @name(%F)"."@ext(%F)
else
%%name = @name(%F)
end |
That's a lot of unnecessary just to get the name of a file out of a path.
The reason to check wether or not a file has an extension is so that you
don't end up with something like "myfile." which would result if there was
no extension on the file but you added a period anyway. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Nov 12, 2003 9:01 am Post subject: |
|
|
How about:
Code: |
%%name = @strdel(%F,1,@len(@path(%F))) |
_________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Nov 12, 2003 1:41 pm Post subject: |
|
|
That won't work...
Code: | %F = %0
%%Name = @strdel(%F,1,@len(@path(%F)))
info %%Name |
I think FreezingFire’s problem isn't that it is impossible. His problem is that that it is using a lot of unnecessary code, while he thinks it should just be a function in VDS... _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Nov 12, 2003 2:40 pm Post subject: |
|
|
That's why I tried to suggest a shorter version.
The point of a programming language is to provide a core set of functions from which developers can create their own higher-level functions that meet their needs. I'm sure everyone has their own personal functions that could be shortened if they were incorporated into VDS itself. But the more functions there are in VDS, the bigger the run-time gets and the slower the interpreter runs. I really think that there are more useful things that could be incorporated into VDS which can't be accomplished in one line of existing code. But that's just my opinion... _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Nov 12, 2003 7:01 pm Post subject: |
|
|
Or, a @pos(/,%A,RIGHT) which would allow us to get the position from
the right of the string. Then we could more easily cut the path out
of the string using @substr().
I think someone made a dsu, or some example codes for doing the above,
but I can't remember... Skit3000 or Codescript I think.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Nov 12, 2003 10:10 pm Post subject: |
|
|
Look out for new String.DLL. It has functions to retrieve anything before/after a specified substring (e.g. "\"), also
anything before/after the LAST occurrence. Last beta with a dozen new funcs will be out shortly.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Nov 12, 2003 11:18 pm Post subject: |
|
|
jules wrote: | That's why I tried to suggest a shorter version.
The point of a programming language is to provide a core set of functions from which developers can create their own higher-level functions that meet their needs. I'm sure everyone has their own personal functions that could be shortened if they were incorporated into VDS itself. But the more functions there are in VDS, the bigger the run-time gets and the slower the interpreter runs. I really think that there are more useful things that could be incorporated into VDS which can't be accomplished in one line of existing code. But that's just my opinion... |
Yes, but you don't see: You've provided a function for @name(), @path(),
and @ext(), why not @fname() or something? It seems that it would be
a logical addition. And, how big does this really make the runtime? I would
not expect it to make it at most 2 kb larger, probably less because it would
most likely take only a few lines in Delphi too. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Nov 12, 2003 11:19 pm Post subject: |
|
|
Dr. Dread wrote: | Look out for new String.DLL. It has functions to retrieve anything before/after a specified substring (e.g. "\"), also
anything before/after the LAST occurrence. Last beta with a dozen new funcs will be out shortly.
Greetz
Dread |
Nice _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
|