Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case statement inside a do while loop

Status
Not open for further replies.

kims212

Programmer
Dec 17, 2007
103
0
0
CA
can i use a case statement inside a do while loop?

here's my formula:

do
(element:= element + 1;
industry_name:=industry_name_shared[element];
select industry_name
case "Ariculture":
dot_spaces[element] = 10
case "Association":
dot_spaces[element] = 6
case "Consulting":
dot_spaces[element] = 10
case "Distribution":
dot_spaces[element] = 4
case "Education":
dot_spaces[element] = 6
case "Finance":
dot_spaces[element] = 4
case 'Food Safety':
dot_spaces[element] = 12
case "Food Service/Restaurant":
dot_spaces[element] = 22
case "Government":
dot_spaces[element] = 8
case "Manufacturing/Processing":
dot_spaces[element] = 30
case "Marketing":
dot_spaces[element] = 8
case "Packaging":
dot_spaces[element] = 10
case "Pest Control":
dot_spaces[element] = 10
case "Research/Laboratory":
dot_spaces[element] = 20
case "Retail/Supermarket":
dot_spaces[element] = 22
case "Sanitation":
dot_spaces[element] = 10
case "Transportation":
dot_spaces[22] = 6
default:
dot_spaces[element] = 0;
)
while element<={#group_position_in_array}-1;

but none of the elements in the dot_spaces array is populated

is it the case inside the do while or is it using array variables inside a case statement or something else?

thanks
kim
 
please, never mind, i figured out what I did wrong.

my apology
kims
 
Please show the formula that worked (including the beginning where you establish the variables).

-LB
 
hi LB

pretty basic oversight actually.

determine_toc_dot_replicate

evaluateafter({@print_toc_page_nos_shared});
WhilePrintingRecords;

shared stringvar array industry_name_shared;

local stringvar toc_dots;
local numbervar array dot_reps;
redim dot_reps [20];

local numbervar element;
local numbervar no_dots;
local stringvar industry_name;

element:=0;
toc_dots:='';

element:=0;
industry_name:='';

do
(element:= element + 1;
industry_name:=industry_name_shared[element];
select industry_name
case "Agriculture": dot_reps[element]:= 8
case "Association": dot_reps[element]:= 9
case "Consultant": dot_reps[element]:= 8
case "Distributor": dot_reps[element]:= 8
case "Education": dot_reps[element]:= 7
case "Finance": dot_reps[element]:= 3
case "Food Safety": dot_reps[element]:= 10
case "Food Service/Restaurant": dot_reps[element]:= 31
case "Government": dot_reps[element]:= 11
case "Ingredient Supplier": dot_reps[element]:= 22
case "Manufacturing/Processing": dot_reps[element]:= 32
case "Marketing": dot_reps[element]:= 7
case "Packaging": dot_reps[element]:= 7
case "Pest Control": dot_reps[element]:= 11
case "Research/Laboratory": dot_reps[element]:= 24
case "Retail/Supermarket": dot_reps[element]:= 22
case "Sanitation": dot_reps[element]:= 6
case "Transport": dot_reps[element]:= 7
default: dot_reps[element]:= 0;
)
while element<={#group_position_in_array}-1;

in fact, I tested it also by
deleting the line: industry_name:=industry_name_shared[element];

and changing the select statement to: select industry_name_shared[element]

and it still worked fine; good to know. I love CR.

this editor doesn't show code formatting, but I do indent my case and align the action code for readability, but I can't do that here so it's a bit jumbled.

thanks
kims
 
Kims

You cn create a code box by entering

["code"]

["/code"]

Code:

Remove "" inside [ ] anything inside code box should follow your indents

Ian
 
ahhh. thanks Ian, that's most informative.

i hope that I can remember for next time i don't see that on the formatting bar, but then i didn't realize about the indent icon either until i tried to find the code tags you mentioned.

are there other 'secret' formatting tags?

thanks
kim
 
ah. thank you again, Ian.

a lot of information there; what a lot of fun one could have.

gracias
kim
 
So are you saying the formula is working as you wished now?

-LB
 

hi LB

yup, works perfectly now; populates the array just the way I needed.

I suppose that if I had a hundred or more industries the "do while" might become a bit unwieldy, but right now it's only 19, i'd never add any more than one per year and the absolute max @ this point is 25. I suppose if the list did become too extensive i'd have to figure out a different way, but the directory has now been sent out and the table of contents worked.

what more can one ask of, well, let's just say, many hours of work. that's it for this year; i'm sure that next year's directory will its own set of challenges.

kim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top