Seite 1 von 1

z88 v14 from command line

Verfasst: Fr 26. Apr 2013, 16:32
von dgebreiter
Hello!

I'm trying to run z88 v14 in batch mode in windows. When I place structure and boundary condition definition files into the z88 folder, I can run

z88r -c -siccg

from the command line and it produces output files exactly as expected. So far, so good.

On the other hand, if I execute the process from a C# program, i.e.

Process pr = new Process();
pr.StartInfo.FileName = "C:\\z88v14os\\bin\\win64\\z88r.exe";
pr.StartInfo.Arguments = "-c -siccg";
pr.Start();

Z88 starts, but returns rather random error messages. A little pop-up appears with a white cross on a red circle and text similar to "+|ü" or "R@" appears.

Any idea why that may be? I would have thought there's no difference between running z88r from the command line and executing the above? Thanks!

P.S.:
I've attached structure and boundary definitions, but again, they work fine when launched from inside v14, as well as when started from the command line.
I've also tries running

String command = "C:\\z88v14os\\bin\\win64\\z88r -c -siccg";
Process pr = new Process();
pr.StartInfo.FileName = "cmd.exe";
string s = "/c " + command;
pr.StartInfo.Arguments = "/c " + command;

which should really emultate exactly the procedure I run when executing the working "z88r -c -siccg" from the command line, but again this fails.

Re: z88 v14 from command line

Verfasst: Fr 26. Apr 2013, 16:55
von dgebreiter
or to reproduce more simply:
running

cmd.exe /c C:\gebr\z88v14os\bin\win64\z88r.exe

from windows the windows start menu will not work, while

running C:\gebr\z88v14os\bin\win64\z88r.exe from the windows start menu
or first running cmd.exe and then manually typing C:\gebr\z88v14os\bin\win64\z88r.exe

will. Any idea why? I really cannot see a difference between the two!

Thanks!

Re: z88 v14 from command line

Verfasst: Sa 27. Apr 2013, 21:50
von mz15
Hello dgebreiter,

in your first post you had this piece of source code.
dgebreiter hat geschrieben:
Process pr = new Process();
pr.StartInfo.FileName = "C:\\z88v14os\\bin\\win64\\z88r.exe";
pr.StartInfo.Arguments = "-c -siccg";
pr.Start();
I think there is an space needed in the "pr.StartInfo.Arguments", like pr.StartInfo.Arguments = " -c -siccg";
so the command line looks like
"C:\\z88v14os\\bin\\win64\\z88r.exe -c -siccg"
and NOT as before
"C:\\z88v14os\\bin\\win64\\z88r.exe-c -siccg"

hope this helps.

regards
mz15

Re: z88 v14 from command line

Verfasst: So 28. Apr 2013, 09:50
von dgebreiter
mz15, thanks for the quick reply. I've checked in the debugger and a space is automatically placed for arguments put in such manner.

Unfortunately the issue about the strange behaviour when started (automatically) from the command line persists and can be easily reproduced using the method of my second post (I've checked on two computers running Windows 7).

Anyway, thanks for your help!

Re: z88 v14 from command line

Verfasst: So 28. Apr 2013, 13:15
von mz15
Hello dgebreiter,

sorry but I'm not familiar with C#, but in C we use a simple Systemcall like
system("C:\\z88v14os\\bin\\win64\\z88r.exe -c -siccg");

Maybe this is also possiblein C#?

regards
mz15

Re: z88 v14 from command line

Verfasst: So 28. Apr 2013, 22:26
von finzi
Hello dgebreiter,

I made some tests and I find out that z88.dyn must be in the starting directory (not in the z88r.exe dir).
The problem is that in WndProc (case WM_CREATE:) even before treating the command line there is a call to lan88r() that open the log file and z88.dyn.
then try first to read the language ("GERMAN" or "ENGLISH") and if z88.dyn is not found all messages are missing. in particulare the message box show an uninitialized string (that are your strange simbols).

The solution is to put the line LANG = 2; at the beginning of lan88r() function so that english is default and you see all errors in English.

If you want to work in a differnt directory, you must get the dir from the command line (change all file names accordingly) and do it before calling lan88r().

Ciao,
Andrea

Re: z88 v14 from command line

Verfasst: Mo 29. Apr 2013, 07:28
von ccad
Hello Andrea,

have you copied the files Z88.DYN and Z88O.COL into the directory where Z88R resides?

Regards

Prof. Rieg

Re: z88 v14 from command line

Verfasst: Mo 29. Apr 2013, 09:20
von dgebreiter
finzi hat geschrieben:I made some tests and I find out that z88.dyn must be in the starting directory (not in the z88r.exe dir).
In my case, I had placed input files I1 and I2 directly into the z88r.exe directory. However, the problem seems to be entirely independent of any problem I am planning to solve.

double-clicking z88r.exe in the windows explorer opens the z88r window as predicted
running c:\z88v14or\bin\win64\z88r.exe from a dos box also works fine (same for win32 executables)

running cmd.exe /c c:\z88v14or\bin\win64\z88r.exe opos up an error message with two or three random symbols
running the process from an external program (in my case c#) fails in the same manner.

ccad hat geschrieben:have you copied the files Z88.DYN and Z88O.COL into the directory where Z88R resides?
Z88O.COL? I don't seem to have this file anywhere. What should it contain?

mz15 hat geschrieben:sorry but I'm not familiar with C#, but in C we use a simple Systemcall like
system("C:\\z88v14os\\bin\\win64\\z88r.exe -c -siccg");

Maybe this is also possiblein C#?
The calls I've illustrated should (in theory) be equivalent to the ones you propose (just a few more lines of code, of course, this being C#). Either way, this does not explain the difference in behaviour when run from the windows command line. I.e. launching z88r.exe in the cmd dos box works, while running cmd.exe /c z88r.exe doesn't.

Re: z88 v14 from command line

Verfasst: Mo 29. Apr 2013, 10:59
von dgebreiter
ok, I think I've found a solution.

The problem was that the current working directory needed to be set prior to launching z88r.

I managed to do so by changing the current directory to the z88r folder first, and then launching z88r.exe from there.

In the windows command prompt
cmd.exe /c "cd /d c:\gebr\z88v14os\bin\win64 && z88r.exe

In C# it's possible to set the working directory by adding the additional StartInfo
pr.StartInfo.WorkingDirectory = "C:\\z88v14os\\bin\\win64";

Thanks everyone for your support!

Re: z88 v14 from command line

Verfasst: Mo 29. Apr 2013, 21:40
von finzi
Hello every body,
I was not clear :(
You can be in a directory, eg C:\TEMP and you want to run z88r.exe present, for example, in C:\BIN.
You must issue the command C:\BIN\z88r.exe but the programm will behave like dgebreiter describes, if in c:\TEMP is not present the file z88.dyn.
Obviously to run the analysis you need to have in the same directory all other needed files (Z88I1.TXT, Z88I2.TXT, Z88I5.TXT, Z88MAT.TXT, 1.txt, ..., Z88ELP.TXT, Z88INT.TXT, Z88MAN.TXT).

If z88.dyn is not present, you have a small bug:
the log file will not record the error and the dialog box will not show the error string.
This behavior is due to the fact a default value is not set for the variable "LANG".
The trivial solution is to initialize the variable at the beginning of the program to a value (1 or 2), but obviously you must recompile the source code. 8)

dgebreiter has found a good solution: move in the directory where all needed files are presnt and then run the z88r, but you have more freedom (have all modell file (including z88.dyn ) in a directory separate from z88r).

Personally I modified the source code to handle a "-d" command line option specifying the working path.

Regards,
Andrea