Bonjour Jean-Marc,

La fonction que vous pouvez utiliser est SGET

Je pense que le code postal est toujours à 5 chiffres en France

Mais le toponyme en France contient souvent un ou plusieurs espaces

Donc, ce que vous pouvez faire, c'est d'abord rechercher le code postal dans la chaîne, en travaillant de l'arrière vers l'avant.

J'ai écrit un petit programme qui tient compte de cette situation.

Ça ressemble à ça

LABEL COMMENCE_DU_PROGRAMME
  -- attention pour votre 'settings'
  --  SET VAR VADRCHANT TEXT = 'Mobile Home Rideau 12 Parc de la Landette 85190 VENANSAULT'   SET VAR VADRCHANT TEXT = 'Mobile Home Rideau 12 Parc de la Landette 24550 Villefranche du Perigord'
  -- count number of spaces
  SET VAR VL_SPACES = (SLOCI(.VADRCHANT,' ',0))
  -- establish total length of string
  SET VAR VL_LENGTH_STRING = (SLEN(.VADRCHANT))
  -- If city-name consists out of 1 word then the zipcode starts at the (last - 1) space
  -- check this
  SET VAR VL_SPACES_BEFORE_CITYNAME = 1
LABEL PRIOR_SPACE
  SET VAR VL_POSSIBLE_START_OF_ZIPCODE = ( (SLOCP(.VADRCHANT,' ',(.VL_SPACES - .VL_SPACES_BEFORE_CITYNAME) )) + 1)
  SET VAR V_ZIPCODE = (SGET(.VADRCHANT,5,.VL_POSSIBLE_START_OF_ZIPCODE) )
  SET VAR VL_SKEEPI = (SKEEPI(.V_ZIPCODE,'012345789'))
  IF V_ZIPCODE = .VL_SKEEPI THEN
      SET VAR V_CITY_NAME = (SGET (.VADRCHANT,(.VL_LENGTH_STRING - (.VL_POSSIBLE_START_OF_ZIPCODE + 5) ), (.VL_POSSIBLE_START_OF_ZIPCODE + 5 + 1) ))
    ELSE
      SET VAR VL_SPACES_BEFORE_CITYNAME = (.VL_SPACES_BEFORE_CITYNAME + 1)
      GOTO PRIOR_SPACE
  ENDIF
LABEL FIN_DU_PROGRAMME
  CLEAR VAR VL_%
  RETURN


Cordialement,

Tony


Op 28-01-2022 om 09:37 schreef Jean-Marc Massé:
SET VAR VADRCHANT TEXT = "Mobile Home Rideau 12 Parc de la Landette 85190 VENANSAULT"

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/e1d45970-4a16-6ccb-2c0e-4b5e4c82eb64%40cio-bv.nl.

Reply via email to