Default Values File-Check All Channels?


JohnyQuick

Recommended Posts

Hi I have a routine that writes default channel values to a file. Sometimes this file gets written to with empty values, which of course I don't want to do. So that if nothings there, when my doc-loads, the default values end up empty, and the user has to reinput, or rivive a backup copy and restart my "defaults" file. I have more than one channel value going into "defaults". do I need to check the stringin for all the channels, or just one? here is a sample. Any help appreciated.

/ Open File and get handle

delay(600) // 600

while(1)

Private FileHandle = File.Open("C:\myfile.txt",0,1,0,1)

// Format string

//Private string strText = FormatTime(XY1.Time[0]) + "," +\

//DoubletoStr(XY1.[0]]) + "," + DoubletoStr(XY2.[0]])

if(DoubletoStr(Dpth[0]) == "") // dpth channel is empty?

file.close(filehandle) //close the file so wont write empty strings to it?

return // no data

endif

try

Private string strText = FormatTime(DPTH.Time[0]) + "," +\

DoubletoStr(DPTH[0])+","+DoubletoStr(BARRELS[0])+","+DoubletoStr(spm1[0])+","+DoubletoStr(spm2[0])+","+ \

DoubletoStr(ACCSTROKES[0])+","+ DoubletoStr(Kelly_Down)+","+ DoubletoStr(BristolSpan)+","+ DoubletoStr(KV0)+","+ DoubletoStr(KVHi)+","+ DoubletoStr(KellyHigh)+","+DoubletoStr(KellyLow)+","+\

DoubletoStr(Reflagdpth)+","+ DoubletoStr(RefVol)+","+ DoubletoStr(pumpout1)+","+ DoubletoStr(pumpout2)+","+ DoubletoStr(Annvolft)+","+ DoubletoStr(lagtime)+","+\

DoubletoStr(ConnectionThreshold) +","+ DoubletoStr(DrillingThreshold) +","+DoubletoStr(CSGID)+","+ DoubletoStr(SHOE)+","+ DoubletoStr(DPOD)+","+ DoubletoStr(BIT)+","+\

DoubletoStr(LithDepth[0])+","+ DoubletoStr(LastSample[0])+","+ DoubletoStr(lnr)+","+ DoubletoStr(Stk)+","+ DoubletoStr(BHA)+","+DoubletoStr(BHALENGTH)+","+DoubletoStr(Well_Name)+","+ DoubletoStr(Company)

// Write data to text file

//catch()

//endcatch

File.Write(FileHandle,strText)

// Close the file

File.Close(FileHandle)

catch()

endcatch

delay(120)

endwhile ////so the check is if doubletostr(mychannel[0])=="" is empty nothings get written to the file. Please check this //code----thanks JQ--repeats every 2 minutes

Link to comment
Share on other sites

Let's chase the cause instead of the symptom: why are you ending up with an empty string? Because the channel was never initialized? Why don't you just initialize all your channels before loading the defaults to be sure there are actually is some default?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.