help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] printf to a file in the correct directory


From: Heinrich Schuchardt
Subject: Re: [Help-glpk] printf to a file in the correct directory
Date: Mon, 23 Feb 2015 22:43:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0

Hello Joel,

the location of your model is irrelevant.
The path used by printf will be relative to the current directory.

You can
- use VBA command CHDIR to set the current directory,
- use absolute paths for printf.

Best regards

Heinrich

On 23.02.2015 20:24, joel mortyn wrote:
> Hi all,
> 
> I have developed an LP with the user interface in MS Excel. I am using
> the printf command to print selected results to a text file as follows:
> printf{s in Sorts} %d\n", SortQc[s] >> "result.txt";
> 
> The result.txt file is located in the same directory as the model and
> data files. When I run the program using the Gusek GUI, all works fine
> and the result.txt file writes to the correct directory. 
> 
> The problem is, that when I run the program from Excel (using the
> command line executable cmd.exe), it saves the result.txt file
> to C:\Users\me\Documents rather than the same directory as the model and
> data files. I have used the same code many times previously in MS Access
> with no issue but this is the first time I've tried it in Excel. I've
> compared the code from Access and Excel and can't find any differences
> so I'm stumped as to what might be the problem. 
> 
> Has anyone else experienced issues like this before?
>  
> Below is some of the VBA code that I am using to run the model from Excel:
> 
> strArgument = strPathName & "glpsol.exe --model " & strModelName & "
> --data " & strFileName
> BatchName = strPathName & "tempfile.bat"
>     
> intEmpFileNbr = FreeFile
> Open BatchName For Output As #intEmpFileNbr
>         Print #intEmpFileNbr, strArgument
> Close #intEmpFileNbr
> Call ShellandWait("cmd.exe /c " & BatchName)
> 
> Thanks for any assistance that you might be able to provide.
> 
> Joel
> 
> 
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]