steveosoule
11/19/2014 - 7:42 PM

Miva - Read File & Loop Over File Contents

Miva - Read File & Loop Over File Contents

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

<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.counter" value="1" />
<mvt:assign name="g.line" value="'initialized'" />

<mvt:while expr="g.line NE NULL">
	<mvt:assign name="g.line" value="gettoken( g.file_contents, g.new_line, g.counter )"/>
	<mvt:assign name="g.counter" value="g.counter + 1" />

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

</mvt:while>