<div dir="ltr"><div><div>Hi Nikos,<br><br></div>I'm sorry if my comment is out of topic as I'm not following the whole discussion, but can you just hardcode the values in the code and allow them to be overridden by the user-specified file? That is much simpler (for both user and GRASS) than handling paths and if the file is short, it does not raise major code cleanness concern. If people need to edit the file, then documentation is the appropriate place.<br><br></div>Vaclav<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 17, 2018 at 10:32 AM, Nikos Alexandris <span dir="ltr"><<a href="mailto:nik@nikosalexandris.net" target="_blank">nik@nikosalexandris.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
Le Mardi 17 avril 2018, Markus Metz a écrit :<br>
> On Tue, Apr 17, 2018 at 4:21 PM, Nikos Alexandris <<a href="mailto:nik@nikosalexandris.net">nik@nikosalexandris.net</a>><br>
> wrote:<br>
> ><br>
> > * Moritz Lennert <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> [2018-04-17 15:56:10<br>
> +0200]:<br>
> ><br>
> >> On 17/04/18 15:31, Nikos Alexandris wrote:<br>
> >>><br>
> >>> Dear developers,<br>
> >>><br>
> >>> is there a way to set a string as the content of a default "answer" for<br>
> >>> the G_OPT_F_INPUT option? I am trying to identify potential cases in the<br>
> >>> grass-addons repository, but I am not sure I have seen something<br>
> related.<br>
> >>><br>
> >>> The G_OPT_F_INPUT offers a field to enter a filename. The default<br>
> >>> "answer", for the parser, will be the name of the file.<br>
> >>><br>
> >>> In addition, a field to "enter values directly" is created. The<br>
> >>> description of this field is: "Enter file content directly instead of<br>
> >>> specifying a file. Temporary file will be automatically created."<br>
> >>><br>
> >>> Can this field be filled with a pre-defined content?<br>
> >>> The use case is to expose, to the user, a pre-defined set of<br>
> >>> reclassification rules. These will help a beginner to get started,<br>
> >>> understand easier and modify rules as he sees fit.<br>
> >><br>
> >><br>
> >> Use the 'answer' parameter:<br>
> >><br>
> >> #% answer : myfilename<br>
> >><br>
> >> Moritz<br>
> ><br>
> ><br>
> > It works: it loads the content of an external file. Are we forced to use<br>
> > external files in such a case? Which means an extra file has to be<br>
> > shipped with the source code.<br>
> > Can we not use an in-script hardcoded string for example?<br>
> <br>
> Be aware that you can't use a hardcoded full path, because depending on the<br>
> installation/user/os, that path may or may not exist. If you use a relative<br>
> path, that path is relative to the current working directory which is of<br>
> course not constant between sessions/installation/user/os. I'm afraid a<br>
> default answer to G_OPT_F_INPUT will cause a lot of trouble.<br>
> <br>
> my2c<br>
> <br>
> Markus M<br>
<br>
</div></div>Ciao Markus.<br>
<br>
Yet my intention was/is to use a hardcoded string of rules. Not a path to a file.<br>
<br>
It appears the only option is to document, the rules, and suggest a copy and paste in to the corresponding field.<br>
<br>
Can the parser be extended in this regard with yet another option? Perhaps I missed some existing option (?).<br>
<br>
Thank you Markus, Nikos<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/grass-dev</a></div></div></blockquote></div><br></div>