Engineer


Shawn

Recommended Posts

Hello Representative,

I have a question regarding "File.Rename(oldname,newname): renames the oldname file to newname" and how to use it.

If the DF program's virtual reset button is selected, I would like to rename the logger CSV file from "FileName.CSV" to "FileName -Reset.CSV," where the file name is actually "FilePath+FileName.CSV."

Logging.BoeingData.strFileName = Registry.strPathToDtStoFlds + "\Boeing Data\FVSMdata_" + component.SerNum.strText + "_" + MyStringVariable + ".csv"

Registry.strPathToDtStoFlds = "C:\MyBriefcase\Desktop"

component.SerNum.strText = <XXXXX> unit serial number

MyStringVariable = formatdatetime("%y%m%d_%H%M%S",StartTime) where StartTime = systime()

 

When a logged file is cut off from a reset, I would like to rename the file as follows:

Example: "FileName.CSV" = FVSMdata_00175_220914_223506.csv to "FileName -Reset.CSV" = FVSMdata_00175_220914_223506 -Reset.csv taking the "FilePath" into account.

The file may have been cut off but may have some relevant data.

 

Thank you,

Shawn

Link to comment
Share on other sites

Just parse out the name.   But first you have to make sure the logging set isn't still attached to the file.  So:

private string oldname = logging.BoeingData.strFileName
logging.BoeingData.strFileName = "c:\junk"  // put something else here
private string newname = left(oldname, getlength(oldname) - 4) + " -Reset.csv"
file.rename(oldname, newname)

You may prefer to search for a ".":

private string oldname = logging.BoeingData.strFileName
logging.BoeingData.strFileName = "c:\junk"  // put something else here
private index = find(oldname, ".", 0)
private string newname
if (index != -1)
   newname = left(oldname, index) + " -Reset.csv"
else
   newname = oldname + " -Reset"
endif
file.rename(oldname, newname)

 

Link to comment
Share on other sites

Thank you,

I tried the 1st option where I replaced "c:\junk" with Registry.strPathToDtStoFlds. This registry path is one folder higher than the actual data folder. This Registry variable allows the DF program to locate the "Boeing Data" folder anywhere on the individual's PC. There are other mechanisms to ensure the "Boeing Data" folder is connected to Registry.strPathToDtStoFlds, so reassigning the logger to one path lower from "Registry strPathToDtStoFlds\Boeing Data" is guaranteed to exist.

   Private String oldname = logging.BoeingData.strFileName
   Logging.BoeingData.strFileName = Registry.strPathToDtStoFlds  // put something else here
   Private String newname = left(oldname, getlength(oldname) - 4) + " -Reset.csv"
   File.rename(oldname, newname)

Unfortunately, the code did not work. 

In the Command/Alert window, I saw the following issues:

1) C1086 One of the parameters was empty: ClearHistory Line 3 - Uncaught error in sequence ClearHistory

09/14/22 23:58:14.780

2) F0011 SHARE.EXE was not loaded, or a shared region was locked.: Startup Line 37 - Uncaught error in sequence Startup

09/14/22 23:58:30.094

For 1) may be the sequences in the reset button don't happen in the correct order using the two Start/Stop Sequences for A) ClearHistory then B). to run the initialization "startup" sequence where this code is placed. This logger path change may have caused the "ClearHistory" sequence not to function even though it should have run first from the DF virtual reset button?

For 2) I don't know, but the file was not renamed in the oldname = logging.BoeingData.strFileName logged location.

Do you have any other suggestions.

Shawn

Link to comment
Share on other sites

The first problem I can't say without more detail, but do note that if you start/stop a sequence using beginseq() / endseq() you cannot predict when it will actually start/stop since it is running in a separate thread.  Truthfully, that applies to logging sets too, which is probably why you have the second problem.  DAQFactory keeps the file open while the logging set is active for performance reasons, and Windows has this cryptic SHARE.EXE error message that, truthfully, is left over from the old DOS days which basically means the file you are trying to manipulate is locked against manipulation, in this case, by the logging set.  You probably need a delay(1) after you update the logging set file name to junk to give it a chance to close the old file.  

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.