Static variables


RodSwan

Recommended Posts

I'm having problems renaming a log file (using the file.rename("xx.txt","yy.txt") function) and suspect problem is multiple calls to the function may be holding file open thus getting the wonderful "Share.exe" not loaded error message So.......

I thought I'd put in a simple lock like:-

Function abc()
static x = 0

if (x == 1)
	return()  //only instance at a time
endif
x = 1  //lockout other calls until I'm finished
..
..
..
x=0
return()

But I couldn't make it work properly so.... reducing the code to a minimum to make something (Anything!) work I got down to...

New Daqfactory drawing.

Just one sequence created:

function fred()
   static x=0
   ?x
   x++
   ?x
return()

nothing else, no devices, no components, no globals ... nothing.

Every time I call it from command/alert window with either "fred()" or "beginseq(fred)" all I get output is:

1

Every time!

I am running this in DaqFactory 5.73b ( as that is the version installed on many systems at numerous customers premises)

I have just tried this on version 5.84 and it seems to work ok.

Is this a known problem in Version 5.73? or maybe is it a problem on my system as I have 5.73 installed in one directory and verion 5.84 installed in another (a DLL Hell conflit?) Is that the cause of my original file.rename problem?

Link to comment
Share on other sites

Archived

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