#APPTYPE CONSOLE DIM s = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$ are$delineated$by$a$single$'dollar'$character,$write$a$program that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ column$are$separated$by$at$least$one$space. Further,$allow$for$each$word$in$a$column$to$be$either$left$ justified,$right$justified,$or$center$justified$within$its$column." DIM lines[] = SPLIT(s, CRLF), tokens[], l, t, length, margin, justify = "center" FOREACH l IN lines tokens = SPLIT(l, "$") FOREACH t IN tokens IF STRLEN(t) > length THEN length = INCR(STRLEN) NEXT NEXT FOREACH l IN lines tokens = SPLIT(l, "$") FOREACH t IN tokens SELECT CASE justify CASE "left" PRINT t, SPACE(length - STRLEN(t)); CASE "center" margin = (length - STRLEN(t)) \ 2 PRINT SPACE(margin), t, SPACE(length - STRLEN - margin); CASE "right" PRINT SPACE(length - STRLEN(t)), t; END SELECT NEXT PRINT NEXT PAUSE