1. ver. 4.0 error load_map.e
- Posted by bernie Mar 18, 2009
- 774 views
----------------------------------- -- a simple example include std/map.e -- declare a map variable map my_map -- file open returns -1 which places 0 in my_map variable my_map = load_map("phony_file.raw") -----------------------------------
The above program is just an excerpt from a large library.
I insert this library in a demo program and the library
will not locate the "phony_file.raw" file
Note error returned is a type_check because load_map
returns ZERO not a VALID POINTER.
But the user is not be informed about open file
failure.
The open file failure will produce the following error:
I think that something needs to report that load_map
failed to open the file not generate the misleading type_check.
----------------------------------- C:\EU_MASTER\INCLUDE\std/map.e:1544 type_check failure, my_map is 0 --> See ex.err Press Enter... -----------------------------------
PS:
Other than that
save_file and load_file work in both text and raw mode
I have a question is there someway for load_map to search
EUINC path for a file ?
2. Re: ver. 4.0 error load_map.e
- Posted by jeremy (admin) Mar 18, 2009
- 743 views
I have a question is there someway for load_map to search EUINC path for a file ?
Bernie,
Take a peek at std/filesys.e, there is a function called locate_file. Here is the online doc page for it:
Jeremy
3. Re: ver. 4.0 error load_map.e
- Posted by bernie Mar 18, 2009
- 750 views
I have a question is there someway for load_map to search EUINC path for a file ?
Bernie,
Take a peek at std/filesys.e, there is a function called locate_file. Here is the online doc page for it:
Jeremy
Thanks Jeremy:
This works ok.
map my_map = load_map(locate_file("my_map.raw",getenv("EUINC")))
4. Re: ver. 4.0 error load_map.e
- Posted by DerekParnell (admin) Mar 18, 2009
- 790 views
----------------------------------- -- a simple example include std/map.e -- declare a map variable map my_map -- file open returns -1 which places 0 in my_map variable my_map = load_map("phony_file.raw") -----------------------------------
The above program is just an excerpt from a large library. I insert this library in a demo program and the library will not locate the "phony_file.raw" file
Note error returned is a type_check because load_map returns ZERO not a VALID POINTER. But the user is not be informed about open file failure.
The open file failure will produce the following error:
----------------------------------- C:\EU_MASTER\INCLUDE\std/map.e:1544 type_check failure, my_map is 0 --> See ex.err Press Enter... -----------------------------------
I think that something needs to report that load_map failed to open the file not generate the misleading type_check.
I understand your concern. However, I took the position that load_map() would in nearly every case work and only rarely would it fail to open the file. The technique to check for a failure here is coded below, but I'll add this to the documentation too.
----------------------------------- -- a simple example include std/map.e -- declare a map variable map my_map object temp -- file open returns -1 which places 0 in my_map variable temp = load_map("phony_file.raw") if equal(temp,-1) then crash("Failed to open the map") end if my_map = temp -----------------------------------
The problem with having the load_map() routine issue a message and/or abort the program is that it can't tell if the calling application considers the call to be a catastrophic failure or not. It could be that the application is 'fishing' for the file or something else.
On the agenda for a future Euphoria is the consideration of proper 'exception' handling.