Run-length encoding: Difference between revisions

Content added Content deleted
mNo edit summary
Line 2,864: Line 2,864:
for i = 0 to len( string ) - 1 // Decode input string char by char
for i = 0 to len( string ) - 1 // Decode input string char by char
ch = mid( string, i, 1 ) // Read character at index
ch = mid( string, i, 1 ) // Read character at index
if intval( ch ) == 0 // Not a digit
if intval( ch ) == 0 // Not a digit
rl =
rl = 1
else
else
rl = intval( mid( string, i ) ) // Read run-length
rl = intval( mid( string, i ) ) // Read run-length
Line 2,871: Line 2,871:
ch = mid( string, i, 1 ) // Read character after run length
ch = mid( string, i, 1 ) // Read character after run length
end if
end if
t = fn StringByPaddingToLength( ch, rl, ch, 0 ) // Assemble string
t = fn StringByPaddingToLength( ch, rl, ch, 0 ) // Assemble temp string
s = fn StringByAppendingString( s, t ) // Add to decoded string
s = fn StringByAppendingString( s, t ) // Add to decoded string
next
next