Hi Giuseppe,
Thanks for the further clarifications. With your additional hints I now
fully understand how the substr function works and why we use *-1 here.
Andreas
On Thu, 29 Dec 2011 15:35:20 +0100, Giuseppe Sucameli wrote:
On Thu, Dec 29, 2011 at 2:18 PM, Giuseppe Sucameli
<sucam...@faunalia.it> wrote:
On Thu, Dec 29, 2011 at 11:25 AM, Andreas Neumann
<a.neum...@carto.net> wrote:
What I do not understand is why I need the *-1 (multiplier).
I usually use -1 in python to get the entire string
...
The function help says:
substr(string,startpos,length)
so we need to use the string length, but also the startpos values
starts from 1, not 0... (and the help doesn't help to understand
it).
looking at the code, here's what the susbstr function calls:
string.mid( startpos -1, length )
Now looking at QString.mid() [1] I can confirm that
using the susbstr function:
startpos starts from position 1 (not 0) and
if length is -1 then all chararcters available from startpos are
returned.
So you can use either substr(id, 1, (id > 0)*-1) or
substr(id, 1, (id > 0)*length(id)), both are valid and working
syntax.
I think we should improve also the help to add those informations.
Regards.
[1]
http://developer.qt.nokia.com/doc/qt-4.7/qstring.html#id-71632fd3-c671-4ae0-9791-bce0d200b511
--
--
Andreas Neumann
Böschacherstrasse 10A
8624 Grüt (Gossau ZH)
Switzerland
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user