SUB DISBIN (string.inp$, format.$, out.string$, delimiter$, er.msg$) ! ! This subprogram recieves a terminal format string ! eg. 123,FRED,654.7,nots ! and converts it into a binary format string of the ! form specified in FORMAT.$ ! ON ERROR GOTO 31000 ! MAP (DTOSTR) doub$ = 8% MAP (DTOSTR) doub MAP (ITOSTR) intg$ = 2% MAP (ITOSTR) intg% ! string.in$ = string.inp$ + delimiter$ string.out$ = "" current.position% = pos (string.in$, delimiter$, 1%) ! WHILE len (format.$) > 0% data.item$ = left$(string.in$, current.position%-1) data.item$ = edit$ (data.item$, 8%) ! discard leading spaces data.item$ = edit$ (data.item$, 128%) ! discard trailing spaces string.in$ = right$ (string.in$, current.position%+1) string.in$ = edit$ (string.in$, 8%) ! discard lead spaces so we can use a space as a terminator data.type$ = left$ (format.$, 1%) IF data.type$ = "D" & THEN GOSUB 10000 & ELSE IF data.type$ = "I" & THEN GOSUB 12000 & ELSE IF data.type$ = "S" & THEN GOSUB 13000 & ELSE er.msg$ = "Invalid data type " + & "in format string: " + & "'" + data.type$ + "'" & \ SUBEXIT ! current.position% = pos (string.in$, delimiter$, 1%) NEXT out.string$ = string.out$ ! SUBEXIT 10000 ! Double precision convert doub = val (data.item$) format.$ = right$ (format.$, 2%) string.out$ = string.out$ + doub$ RETURN ! 12000 ! Integer convert intg% = val (data.item$) format.$ = right$ (format.$, 2%) string.out$ = string.out$ + intg$ RETURN ! 13000 ! String convert end.string.pointer% = pos (format.$, "%", 2%) str.len% = val (seg$ (format.$, 2%, end.string.pointer%-1)) data.item$ = fn.trim.quotes$ (data.item$) data.item$ = edit$ (data.item$, 8%) ! discard leading spaces data.item$ = edit$ (data.item$, 128%) ! discard trailing spaces data.string$ = left$ ((data.item$ + space$ (str.len%)), str.len%) format.$ = right$ (format.$, end.string.pointer%+1) string.out$ = string.out$ + data.string$ RETURN ! {BL:[101,5]FNUNQUOTE.B4S} ! 31000 er.msg$ = ert$(err) + " in module " + ern$ ! 32767 SUBEND