[Gvsig_english] gvSIG 1.11: add consecutive numbers to selection?

Antonio Falciano afalciano at yahoo.it
Wed Mar 28 14:36:49 CEST 2012


Hi all,
field expression is based on the values of the same row, however field
calculator commands are Jython's functions. So it's possible to memorize
a variable during field calculations using the advanced tab, for
instance loading and evaluating the following script consecutiveN.py:

#consecutiveN.py
from javax.swing import JOptionPane

def consecutiveN():
   global index
   try:
     if rec() == 0:
       index = 0
     else:
       index = index + 1
   except:
       index = ''
   return index

# Usage: consecutiveN()
JOptionPane.showMessageDialog(None, 'Usage: consecutiveN()', 
"consecutiveN", JOptionPane.INFORMATION_MESSAGE)

Its usage is very simple. If the first record is not selected, the index
will be 1-based and so consecutiveN() will do the trick, otherwise it
will start from 0 and so consecutiveN()+1 would be necessary.

Cheers,
Antonio

Il 27/03/2012 20.17, Francisco Puga ha scritto:
> Seems like a simple request but after think a bit more, i don't find a
> way to accomplish it. Field Expression is based on the values of the
> row actual being processing, it hasn't have memory, so the program
> doesn't know which is the next number to use.
>
> Sorry.
>
> El día 27 de marzo de 2012 19:07, spatialjoeescribió:
>> Hi Francisco,
>>
>> thanks for your advice. With sextante numbering individual selections of a
>> layer will result in new individual shapefiles which then can be merged back
>> into one. Not sure if I like this but that's the way it'll work.
>> Nonetheless pointing to sextante was useful anyway. I somehow got mentally
>> stuck  with rec()+1.
>> Thanks again!
>>
>> best,
>>
>> Johannes
>>
>> --
>> View this message in context: http://osgeo-org.1560.n6.nabble.com/gvSIG-1-11-add-consecutive-numbers-to-selection-tp4661202p4661647.html
>> Sent from the gvSIG users mailing list archive at Nabble.com.
>> _______________________________________________
>> Gvsig_internacional mailing list
>> Gvsig_internacional at listserv.gva.es
>>
>> To see the archives, edit your preferences or unsubscribe from this mailing list, please access this url:
>>
>> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>
>
>

-- 
Antonio Falciano
http://www.linkedin.com/in/antoniofalciano


More information about the Gvsig_internacional mailing list