Display arguments sliced from a sequence
- Posted by alrobnett Dec 27, 2018
- 1042 views
To display a series of 64 items at specific locations, I need to pick a series of formatting information from a long sequence. The original matrix, for use with printf, looked like:
rn_display_format = { { 0, 35, "%12s", 1, 0, 12}, { 1, 16, "%12s", 2, 0, 12}, { 1, 58, "%12s", 2, 1, 12}, { 2, 6, "%12s", 4, 0, 12}, { 2, 26, "%12s", 4, 1, 12}, { 2, 48, "%12s", 4, 2, 12}, { 2, 68, "%12s", 4, 3, 12}, { 3, 1, "%8s", 8, 0, 8}, { 3, 11, "%8s", 8, 1, 8}, { 3, 21, "%8s", 8, 2, 8}, { 3, 31, "%8s", 8, 3, 8}, { 3, 43, "%8s", 8, 4, 8}, { 3, 53, "%8s", 8, 5, 8}, { 3, 63, "%8s", 8, 6, 8}, { 3, 73, "%8s", 8, 7, 8}, ... etc.
My test of extraction from a sequence for use with display is:
include std/io.e include std/filesys.e include std/error.e include std/console.e include std/graphics.e include std/sequence.e include std/cmdline.e include std/convert.e integer key_code, start_number, stop_number sequence test_sequence = "123456789" sequence display_portion, format_string, slice_start, slice_stop clear_screen() position (4,20) format_string = {1,2,3,4,5,6,7,8,9} slice_start = slice(format_string, 4,4) start_number = to_number(slice_start) slice_stop = slice(format_string, 9,9) stop_number = to_number(slice_stop) display_portion = slice(test_sequence, start_number, stop_number) display(display_portion) key_code = wait_key()
There are no error messages, but it displays the entire string
123456789
whereas I expected
456789
What's wrong?