intfiction.org

The Interactive Fiction Community Forum
It is currently Tue Aug 14, 2018 5:41 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Mar 01, 2018 1:42 am 
Offline

Joined: Mon Dec 30, 2013 4:55 am
Posts: 96
I don't know if this comes from Gargoyle, Bocfel or others, but when I save and restore data from Inform6 in a file, the default file name is "Untitled.sav" and not my file name.
With Frotz (David Griffith), I can do it but not with Gargoyle.
http://inform-fiction.org/zmachine/standards/z1point1/sect15.html#save
Quote:
***[1.0] The extension also has (optional) parameters, which save a region of the save area, whose address and length are in bytes, and provides a suggested filename: name is a pointer to an array of ASCII characters giving this name (as usual preceded by a byte giving the number of characters). See S 7.6. (Whether Infocom intended these options as part of Version 5 is doubtful, but it's too useful a feature to exclude from this Standard.)
Code:
Array nom_fichier string "my_file_name";

Array data  buffer 256;

[ puts pt   i;
   i = 0;
   while (i < pt-->0) {
      print (char) pt->(WORDSIZE+i);
      i++;
   }
];

[ main key flag len;
   
   @output_stream 3 data;
   print "Diversis et latrociniis quidam diu motibus spectaculo et
         apud cladibus feris consortes diu diu sane adulescentem morem
         feris iactitabant raris.";
   @output_stream -3;

   len = data-->0;

   @save data len nom_fichier -> flag;
   if (flag == 0) print "Save failed.^";

   @restore data len nom_fichier -> flag;
     if (flag == 0) print "Restore failed.^";

   puts(data);
   
   new_line;
   .readkey;
   @read_char 1 ->key;
];


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Mar 01, 2018 2:16 am 
Offline
User avatar

Joined: Wed Oct 14, 2009 4:02 am
Posts: 2506
There's a comment in Bocfel's code saying "This should be able to suggest a filename, but Glk doesn’t support that." But Glk should be able to support that...

https://github.com/garglk/garglk/blob/8 ... erp.c#L766

Maybe the issue is the spec describes a DOS style 8.3 filename, which Glk doesn't support. But Bocfel could do more to try to support what is given, either by chopping the filename at the . or by converting it to an underscore.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Mar 01, 2018 2:09 pm 
Offline

Joined: Wed Aug 18, 2010 1:15 pm
Posts: 79
I know it's a narrow reading, but that comment (about Glk not supporting filenames) is based on the language in the standard which says that the filename is suggested; and Glk's glk_fileref_create_by_name doesn't, or at least isn't required to allow the user to be able to modify the name. That is, it's no longer a suggested name, but a mandated name. The comment means that Glk doesn't allow filenames to be suggested, not that they cannot be used.

I think my concern (I wrote that comment 7 years ago so my memory is fuzzy) was that by not allowing a suggested name, you ran the risk of a game being able to arbitrarily overwrite files. You'd have to rely on the Glk library to not allow that, basically.

I'm not sure the best approach here. Ideally there'd be a way to require the user to confirm the name with the standard interface (e.g. with a dialog box on Glk implementations that support them). An alternative, I suppose, would be "in-line" saving, using Glk directly. The result would be a UI that looks similar to how Frotz does it.

I'll also ponder adding a Gargoyle extension to allow a filename to be suggested to the save dialog, since at least 99.9% of Bocfel users will be using it through Gargoyle.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Mar 01, 2018 8:34 pm 
Offline
User avatar

Joined: Wed Oct 14, 2009 4:02 am
Posts: 2506
Ah, but that's more of an issue when the fourth operand 'prompt' is provided, isn't it? Glk doesn't let you ask for a filename with a suggested one, but if @save is only given three operands then you can just use the provided filename.

Quote:
As of Standard 1.1 an additional optional parameter, prompt, is allowed on Version 5 extended save/restore. This allows a game author to tell the interpreter whether it should ask for confirmation of the provided file name (prompt is 1), or just silently save/restore using the provided filename (prompt is 0). If the parameter is not provided, whether to prompt or not is a matter for the interpreter - this might be globally user-configurable. Infocom's interpreters do prompt for filenames, many modern ones do not.


It was more ambiguous before 1.1. Now I think it's clear that you can just use the filename, as a mandated one. With a .glkdata extension the risk to overwriting sensitive files is as low as for any other Glk game.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group