Coding Question

Hey Everyone,
I have a question, I think it may be a stupid question sorry, but I cannot figure it out. I am using this code:

	#set($x = 0)##
				#foreach($expertCatagory in $expertin)##
					#if($x <= 6)##
					$rx.asmhelper.getTitle($expertCatagory).replaceAll("-"," "),
						##set( $assemblyResult = $sys.asm.assemble( [$expertCatagory] ).get(0).toResultString() )##
						##<li>$sys.assemblyItem.getVariables()</li>
						#set($x = $x + 1)##
					#end##
    			#end##

.
In a template and it works fine in separating $expertcategory listings(

$rx.asmhelper.getTitle($expertCatagory).replaceAll("-"," "),

) with a comma. What I cannot get it to do is NOT put a comma after the last entry?

It renders like this:
Aviation Security, Intelligence, Propaganda, Counterterrorism, Personnel Security, Psychological Consequences of War, Transnational Crime,

I need NO comma after the last entry?

Little help?

Thanks!!!
MJW

It is a little easier if you flip this around and put a comma before every item but the first. This way you can use the $velocityCount variable that is always available in a loop in velocity. e.g.

#if($velocityCount > 1 ),#end

Be careful with the spacing also, you may not care in html as all the newlines and spaces get replaced with a single space in the page, but the comma currently will be followed by a new line character unless you follow with a ##. Velocity respects all spaces and newlines but removes everything on the newline after the ##. So if you want to make the list appear as one string in the source you have to remove the indentation and make careful use of ## I see you have this on some but not other lines. The spaces or tabs before the statement will also be output.

Perfect thanks!

[QUOTE=sbolton;19912]It is a little easier if you flip this around and put a comma before every item but the first. This way you can use the $velocityCount variable that is always available in a loop in velocity. e.g.

#if($velocityCount > 1 ),#end

Be careful with the spacing also, you may not care in html as all the newlines and spaces get replaced with a single space in the page, but the comma currently will be followed by a new line character unless you follow with a ##. Velocity respects all spaces and newlines but removes everything on the newline after the ##. So if you want to make the list appear as one string in the source you have to remove the indentation and make careful use of ## I see you have this on some but not other lines. The spaces or tabs before the statement will also be output.[/QUOTE]

Just as a follow up, your suggestion worked perfectly thanks and the code I used is:

            <p class="note">
    			<span>Expertise:</span>
    			<ul>
    				#set($x = 0)##
				#foreach($expertCatagory in $expertin)##
				#if($x <= 6)##
				<li>$rx.asmhelper.getTitle($expertCatagory).replaceAll('-'," ")</li>
				[$expertCatagory] ).get(0).toResultString() )##
				#set($x = $x + 1)##
				#end##
    			

[QUOTE=sbolton;19912]It is a little easier if you flip this around and put a comma before every item but the first. This way you can use the $velocityCount variable that is always available in a loop in velocity. e.g.

#if($velocityCount > 1 ),#end

Be careful with the spacing also, you may not care in html as all the newlines and spaces get replaced with a single space in the page, but the comma currently will be followed by a new line character unless you follow with a ##. Velocity respects all spaces and newlines but removes everything on the newline after the ##. So if you want to make the list appear as one string in the source you have to remove the indentation and make careful use of ## I see you have this on some but not other lines. The spaces or tabs before the statement will also be output.[/QUOTE]