How do I remove part of a path?

Peter Brigham MD pmbrig at gmail.com
Mon Aug 1 15:01:40 EDT 2011


When you replace item 4 of tStr with empty, you don't delete the item itself, you just make the item empty:

put "a/b/c/d/e/f" into k
set itemdel to "/"
put "" into item 4 of k
put k

  -> a/b/c//e/f

What you need to do is delete the item itself:

put "a/b/c/d/e/f" into k
set itemdel to "/"
delete item 4 of k -- note the change
put k

  -> a/b/c/e/f

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig



On Aug 1, 2011, at 1:11 PM, Pete wrote:

> Another variant might be:
> 
> replace "/" & item 4 of myURL with empty in myURL
> 
> As an aside, I have found a very frequent need to parse out tab-delimited
> strings and had been doing it by setting the itemdelimiter to tab and back
> again.  I got myself in trouble so many times by forgetting to set the
> itemdelimiter back to its original value that I wrote a short handler to do
> this:
> 
> function tabItem pitem,pstring
>   set the itemdelimiter to tab
>   return item pitem of pstring
> end tabItem
> 
> put tabItem(3,myString) into myColumn
> 
> Since the itemdelimiter setting is local to a handler, don't need to
> save/reset it.  Saved me a few hundred lines of coding and eliminated
> itemdelimiter debuggung issues.
> 
> I wish there was a tab-delimited chunk type native to LC.  I see there is a
> columndelimiter property that is set to tab but I think it's only use is for
> combine and split on arrays.  Would be great to be able to do "put column 3
> of myString into myColumn".
> 
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> 
> 
> 
> 
> On Mon, Aug 1, 2011 at 8:38 AM, Michael Kann <mikekann at yahoo.com> wrote:
> 
>> Jim,
>> Now I get it. Good one-liner.
>> Mike
>> 
>> --- On Mon, 8/1/11, Jim Ault <jimaultwins at yahoo.com> wrote:
>> 
>> From: Jim Ault <jimaultwins at yahoo.com>
>> Subject: Re: How do I remove part of a path?
>> To: "How to use LiveCode" <use-livecode at lists.runrev.com>
>> Date: Monday, August 1, 2011, 10:28 AM
>> 
>> "itemToParse" is a variable name I created that contains the string, such
>> as
>> 
>> "http://domain.com/subfolder/subfolder/page.html"
>> 
>> Sorry about the confusion.
>> Perhaps I should have used "tStringOfItemsToParse"
>> 
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list