Hello,
I have problems with substring or I don´t get the definition. * substring(string, index)* Returns a substring of *string* that begins at *index* and extends to the end of *string*. Assume that this is dir: C:\Dokumente und Einstellungen\Johannes Breu\Eigene Dateien\Platz\Images\IN12/Image0006.tif m=dir; u="Images"; n=substring (m,u); print(n); Now I expect n=Images\IN12/Image0006.tif Instead of this I get an error message: n=substring (m,u<)>; What´s wrong? |
On Wednesday 01 October 2008 16:57:10 Johannes Breu wrote:
> Hello, > > I have problems with substring or I don´t get the definition. > * > substring(string, index)* > Returns a substring of *string* that begins at *index* and extends to the > end of *string*. > > Assume that this is dir: C:\Dokumente und Einstellungen\Johannes > Breu\Eigene Dateien\Platz\Images\IN12/Image0006.tif > > m=dir; > u="Images"; > n=substring (m,u); > print(n); > > Now I expect n=Images\IN12/Image0006.tif > > Instead of this I get an error message: > n=substring (m,u<)>; > > What´s wrong? 'u' is not a number? G |
In reply to this post by Johannes Breu
Hi Johannes,
it should be: m=dir; u="Images"; uIndex = indexOf(m,u); if (uIndex<0) exit("Error: Directory name does not contain "+u); n=substring (m,uIndex); print(n); Michael ________________________________________________________________ On 1 Oct 2008, at 17:57, Johannes Breu wrote: > Hello, > > I have problems with substring or I don´t get the definition. > * > substring(string, index)* > Returns a substring of *string* that begins at *index* and extends > to the > end of *string*. > > Assume that this is dir: C:\Dokumente und Einstellungen\Johannes > Breu\Eigene > Dateien\Platz\Images\IN12/Image0006.tif > > m=dir; > u="Images"; > n=substring (m,u); > print(n); > > Now I expect n=Images\IN12/Image0006.tif > > Instead of this I get an error message: > n=substring (m,u<)>; > > What´s wrong? |
In reply to this post by Johannes Breu
Hi,
On Oct 1, 2008, at 11:57 AM, Johannes Breu wrote: > Hello, > > I have problems with substring or I don´t get the definition. > * > substring(string, index)* > Returns a substring of *string* that begins at *index* and extends > to the > end of *string*. > The index value must be a zero-based position for the substring to begin. I think you want to add a step using indexOf() str = "C:\Dokumente und Einstellungen\Johannes Breu\Eigene Dateien \Platz\Images\IN12/Image0006.tif"; ix = indexOf(str, "Images"); n = substring(str, ix); print(n); I just noticed that on my Mac OSX (ImageJ 1.41) the forward slash disappears but it might work on you Windows machine just fine. Cheers, Ben > Assume that this is dir: C:\Dokumente und Einstellungen\Johannes > Breu\Eigene > Dateien\Platz\Images\IN12/Image0006.tif > > m=dir; > u="Images"; > n=substring (m,u); > print(n); > > Now I expect n=Images\IN12/Image0006.tif > > Instead of this I get an error message: > n=substring (m,u<)>; > > What´s wrong? |
In reply to this post by Johannes Breu
>Hello,
> >I have problems with substring or I don´t get the definition. >* >substring(string, index)* >Returns a substring of *string* that begins at *index* and extends to the >end of *string*. > >Assume that this is dir: C:\Dokumente und Einstellungen\Johannes Breu\Eigene >Dateien\Platz\Images\IN12/Image0006.tif > > m=dir; > u="Images"; > n=substring (m,u); > print(n); > >Now I expect n=Images\IN12/Image0006.tif > >Instead of this I get an error message: >n=substring (m,u<)>; > >What´s wrong? Just read the current manual "Built-in Macro Functions " carefully: substring(string, index1, index2) Returns a new string that is a substring of string. The subegins at index1 and extends to the character at index2 . HTH -- Herbie ------------------------ <http://www.gluender.de> |
In reply to this post by Ben Tupper
>str = "C:\Dokumente und Einstellungen\Johannes Breu\Eigene
>Dateien\Platz\Images\IN12/Image0006.tif"; >ix = indexOf(str, "Images"); >n = substring(str, ix); >print(n); > >I just noticed that on my Mac OSX (ImageJ 1.41) the forward slash >disappears but it might work on you Windows machine just fine. > >Cheers, >Ben For me, the backward slashes disappear with OSX... (C:Dokumente und EinstellungenJohannes BreuEigene DateienPlatzImagesIN12/Image0006.tif) Best -- Herbie ------------------------ <http://www.gluender.de> |
In reply to this post by Gluender-2
Hi all,
Has anyone developed a Richardson-Lucy Plugin? Regards, Dale |
Free forum by Nabble | Edit this page |