steveosoule
10/30/2015 - 5:11 PM

Miva - Loop Over File with Pagination

Miva - Loop Over File with Pagination

<mvt:assign name="g.new_line" value="asciichar(10)"/>
<mvt:assign name="g.file_path" value="'Merchant5/s01/data.csv'" />

<mvt:if expr="NOT fexists(g.file_path)">
	File does not exist
	<mvt:exit/>
</mvt:if>

<mvt:assign name="g.file_length" value="file_read(g.file_path, 'data', g.file_contents)" />


<mvt:assign name="g.Per_Page" value="10" />
<mvt:assign name="g.Start_At" value="g.Offset + 1" />
<mvt:assign name="g.Counter" value="g.Start_At" />
<mvt:assign name="g.End_At" value="g.Start_At + g.Per_Page" />

<mvt:assign name="g.current_line_string" value="'initialized'" />
<mvt:while expr="g.current_line_string NE NULL AND g.Counter LE g.End_At ">
	<mvt:assign name="g.current_line_string" value="gettoken( g.file_contents, g.new_line, g.Counter )"/>
	<mvt:assign name="g.Counter" value="g.Counter + 1" />

	<mvt:if expr="len(g.current_line_string) GT 1">
		&mvt:global:line;<br>
	</mvt:if>
</mvt:while>

<mvt:if expr="g.current_line_string EQ NULL">
	Completed
<mvt:else>
	<meta http-equiv="refresh" content="0;URL='&mvte:global:domain:mm_url;Screen=&mvte:page:code;&Offset=&mvte:global:End_At;'" />
</mvt:if>