20. Remove Spaces
Description
Code
""
// Turn off ASKing
ASK NONE
// Set up a loop: One cycle for each character in the text variable
SET loopLimit-n[ LENGTH( TextVar ) ] TO 1
// Perform the loop: Each pass examines one character
REPEAT Loop
// Is this a space?
SET char TO MID( TextVar, COUNTER, 1 )
IF char != " "
// No ... so keep it
RESULT + char
END IF
// Reset the loop
SET loopLimit-n TO UNANSWERED
END REPEAT
ASK DEFAULT
Explanation
This computation will remove all whitespace from a text variable or string. (Whitespace is a tab, return or space). So the string "X VJ7-002 z" will become "XVJ7-002z".
The computation uses the loop described in Computation 15: Loops Via Repeat to go through the string in TextVar character-by-character, and appends to the RESULT only those characters that are not whitespace.
See also, Computation 68: Strip Punctuation, Computation #0130: Multi-line to Single-line, and Computation #0141: Clean Up Spaces.