Re: load_map in map.e - unstructured programming example.
- Posted by mattlewis (admin) May 09, 2014
- 1297 views
gimlet said...
":=" = "assignment" "==" = "comparison" ",$" = "placeholder" ", $" = "erroneous - no spaces" "--" = "comment ---- to end of line"Perhaps these will suffice.
Thanks, I think that's helpful. I copied that into a file (gimlet.map), and ran the following:
include std/map.e include std/console.e procedure print_map( sequence file ) printf(1, "\nmap loaded from %s\n", { file } ) map gimlet = load_map( file ) sequence keys = map:keys( gimlet ) for i = 1 to length( keys ) do printf(1, "key[%s] value[%s]\n", { keys[i], map:get( gimlet, keys[i] ) } ) end for end procedure map foo = map:new() map:put( foo, `:=`, `==` ) map:put( foo, `==`, `comparison` ) map:put( foo, `,$`, `placeholder` ) map:put( foo, `, $`, `erroneous - no spaces` ) map:put( foo, `--`, `comment ---- to end of line` ) map:save_map( foo, "foo.map" ) print_map( "gimlet.map" ) print_map( "foo.map" )
Here was the output:
$ eui gimlet.ex map loaded from gimlet.map key[--] value["comment --] key[, $] value[erroneous - no spaces] key[":] value[" = "assignment"] key["] value[=" = "comparison"] map loaded from foo.map key[--] value[comment ---- to end of line] key[, $] value[erroneous - no spaces] key[":] value[" = "=="] key["] value[=" = "comparison"]
Also, foo.map contained:
"\-\-" = "comment \-\-\-\- to end of line" "==" = "comparison" ":=" = "==" ",$" = "placeholder" ", $" = "erroneous \- no spaces"
Note that foo.map was created by save_map(). And load_map() returned something very different from what it should have been.
Matt