Dear all,
How can I use GAMS in Visual Studio 2005 .net?
Although I can compile the examples files in GAMS directory, I can’t produce the exe file.
Thanks
Hu.
\
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
Hi Hu
I am using Visual Basic . Net instead of C++, but I understand that the logic is the same it just changes a little bit the syntax…
This is my code, and I will tell you a pair of tips of how I made it work…
Sub EjecutarGAMS()
Dim p As Process = New Process
p.StartInfo.FileName = “C:\Program Files\GAMS23.5\gams.exe”
p.StartInfo.WorkingDirectory = “C:\Users\JM\Documents\gamsdir\projdir”
p.StartInfo.Arguments = " C:\GAMSFiles\Scheduling.gms"
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
p.Start()
p.WaitForExit()
End Sub
TIPS:
Now, a very important thing is that you must copy the gamslice.txt file to the folder C:\Program Files\GAMS23.5\ or the correspondent folder on your machine. It doesn’t matter that you have directed your GamsIde Options to the location of you license, if you do not copy the license to this folder, it won’t work the .exe file while running gams externally.
A second tip (though I don’t know if it was my mistake or some kind of bug), is something that I don’t understand: I couldn’t make the “.arguments†instruction to use any folder or address that I wanted, I don’t know why it didn’t work with other folders…I watched this .argument option that I typed above on someone else’s program, so I created the C:\GAMSFiles\ folder, and put there my .gms file and it run…I have never understood why…so, my suggestion is that you might try with your current file location, and if it doesn’t, try with this GamsFiles folder…As I said, it sounds stupid, and with no logic, but it worked for me…
Regards
PD:
I think you should use something like the following for C++
{
Process p = new Process();
p.StartInfo.FileName = @“F:\Program Files\GAMS23.3\gams.exe”;
p.StartInfo.WorkingDirectory = @“F:\C#-GAMS\CSGAMS\CSGAMS\bin\Debug\gamsprogram”;
p.StartInfo.Arguments = “"” + @“F:\C#-GAMS\CSGAMS\CSGAMS\bin\Debug\gamsprogram\Untitled_1.gms” + “" LO=0 --runid=” + “0”;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
MessageBox.Show(“”);
}
\
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.