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 


A function to strip the path off of a path & filename

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Nov 11, 2003 8:07 pm    Post subject: A function to strip the path off of a path & filename Reply with quote

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. Confused

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


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

PostPosted: Wed Nov 12, 2003 9:01 am    Post subject: Reply with quote

How about:
Code:

  %%name = @strdel(%F,1,@len(@path(%F)))

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed Nov 12, 2003 1:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
jules
Professional Member
Professional Member


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

PostPosted: Wed Nov 12, 2003 2:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


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

PostPosted: Wed Nov 12, 2003 7:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed Nov 12, 2003 7:59 pm    Post subject: Reply with quote

I made a DSU file to do that, but there are some DLLs available which do the same as well. I just reverse the text with a repeat loop, and than use @pos() to get the position of a string from the right side of the input text... Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
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: Wed Nov 12, 2003 10:10 pm    Post subject: Reply with quote

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. Cool

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
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Nov 12, 2003 11:18 pm    Post subject: Reply with quote

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. Confused

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


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Nov 12, 2003 11:19 pm    Post subject: Reply with quote

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. Cool

Greetz
Dread


Nice Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Wish List 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