Jump to content

 
Photo

For Next Loop for Labelling

- - - - -

  • Please log in to reply
4 replies to this topic

#1
helix

helix

    Newbie

  • Validated Member
  • Pip
  • 3 posts
  • United Kingdom

Hi all,

I have been trying to label a series of depth contours from the field [DEPTH] at 500m intervals in a series that goes from 0m down to -7000m with a VBScript expression in ArcMap 10.

I think I need to use a 'for next loop' but it's the first time I have had to use such a loop in anger for a label expression. I have tried a few constructs but I am missing something to make it work correctly.

My programming skills are limited so I have decided to save embarrassment by no posting my attempts.

Any help appreciated,

Thanks

#2
kass

kass

    Newbie

  • Validated Member
  • Pip
  • 7 posts
  • Gender:Male
  • United States

I think you want to look into the MOD operator, not 'for next' loops.

Here's a quick explanation from ESRI:
http://webhelp.esri....ls_for_contours

MOD is a operator that returns the remainder, so you give it
If ([DEPTH] Mod 500) = 0

it will divide the depth by 500, and whenever it divides evenly (the remainder equals 0), it will trigger the "If". I always need some trial and error to get it do what I want it to do.

#3
helix

helix

    Newbie

  • Validated Member
  • Pip
  • 3 posts
  • United Kingdom

Cheers kass,

It worked great.

I knew the MOD operator existed but I didn't really understand it's function. I had actually tried to do something similar with the divide operator but couldn't get it to work as I couldn't find a way to reference the remainder.

Thanks for the link I normally fall back on creating another field to index the labels as in the guide, but as this was a numeric series and for once I had time to experiment I new there had to be a more elegant way.

Thanks again.

#4
jrat

jrat

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 143 posts
  • Gender:Male
  • Location:Hagerstown, MD
  • United States

Maybe I am just not understanding what you were doing, but why did you need a vbscript to set up your lables? if you had the depth already in a field couldn't you label on the depth then add an sql query definition to the lables?

#5
helix

helix

    Newbie

  • Validated Member
  • Pip
  • 3 posts
  • United Kingdom

I tend to label using a VBScript expression as I am dabbling with learning some simple programming. I used to program in basic on the C64 and BBC about 20 -25 years ago. So I decided to play with visual basic as it was the logical progression to the old school basic and was is used in the MS office suite and esri products. I should have by rights looked at java or preferably python; but to be brutally honest I don't have the time. VB allows me to try to remember something I once knew and it doesn't annoy the boss when I write code on works time as I'm just doing my job.

I'm interested in your suggested SQL solution if it would achieve the same goal, I always keen to learn more and am happy to research things until I hit a brick wall but I don't understand how the expression's output would be picked up by arcmap's labelling tool.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->