Error code when trying to write a file using PacSim


I am designing a strategy that involves some data logging, using PAC Sim until my hardware is ready. I am trying to use PAC Control to carry out the logging and currently am getting an error status -407 when I attempt to open the communication handle with the OptoScript below:

//Generate data log string to append to file
iDataLogLength = GetLengthOfTable(DataLogVars);
sTransmitDataRow ="";
for nDataLogIndex = 0 to iDataLogLength-1 step 1

//Open communication handle
comstatus = OpenOutgoingCommunication(DataLogHandle);

if (comstatus==0) then
//SetEndOfMessageTerminator(DataLogHandle, CHR(10));

comstatus = CloseCommunication(DataLogHandle);

Digging around the forums, this error code is due to an unavailable file for PAC Sim to read. (see here)

I tried to look for my PAC Sim install in C:\Windows\system32\OptoCom but it is not present there. The forum posts are somewhat old so I am not sure if the installation directory for PAC Sim has been changed. I have no problem running all of my strategy so I expect PAC Sim to be running fine somewhere in my computer. I checked the SysWOW64 directory and could not find an OptoCom directory either. Furthermore, the PAC Control documentation suggests that the communicatiion handle should create any directories that are not present when the comm handle is open: “a — Opens a file for writing at the end of the file (appending). If the file doesn’t exist, it is created.” (pg 280 of PAC Control users guide).

Any suggestions on how to further troubleshoot the issue would be welcome.


Hi there and welcome to the forums!

It will create the file, not the directory.
If you make a test file not in that directory path, you can find the file base path, then make your directory, then you will be able to proceed without that error.

BTW, thanks a heap for doing the searches. It really helps to know what you have found and tried.

Hello Beno,

Thanks for your reply and welcome. I just wanted to clarify your suggestion: Would you suggest I create a new file outside of PAC Control and then attempt to write to it by pointing my comm handle to that file? I am not sure how that will help me find PAC Sim’s base path, but perhaps I am not fully understanding what your message states. Any clarification would be very helpful!


Meant to say, make the file without any directory path in it…
So change this line:
to this

I don’t think Windows is happy about the tilde (~) so just write your file with no path to start with, once you find where its written, then manually make your desired directory and then in your comm handle, put the whole path in (no tilde).
See how that goes.

Hi Beno,

I tried your suggestion and found that PAC Sim wrote the file to its normal install location of: C:\Program Files (x86)\Opto22\PAC Project 10.4\PAC Sim. Kinda surprised that this was so different from what showed up in the forums, but I did not see any documentation that would suggest this change in default directory. If I specified a different path to some other location in my computer I created(C:\Optostrategy) its also worked fine.

Thanks for your help and hope this might help other new users!