jim0203 Posted April 19, 2009 Posted April 19, 2009 Is it possible to clear all global variables simply? Or do I have to clear each one by hand?
comment Posted April 19, 2009 Posted April 19, 2009 Is it possible to clear all global variables simply? Yes - close the file.
IdealData Posted April 20, 2009 Posted April 20, 2009 You could also script it. Use the [color:red]Set Field step to clear the necessary globals.
jim0203 Posted April 20, 2009 Author Posted April 20, 2009 Re: closing the file, that's not really an option as I want to clear the globals and keep using the file. I've ended up clearing all the global variables by hand in one script; this wasn't too difficult. Weird how FM doesn't have a script step to do this automatically.
comment Posted April 20, 2009 Posted April 20, 2009 No offense, but the weird part here is your request. The very purpose of global variables is to persist until the file is closed. If you don't want them to hang around, why make them global in the first place?
jim0203 Posted April 20, 2009 Author Posted April 20, 2009 None taken! It is a bit of a weird request. I'm trying to get round some hacky bits of my project where I've used globals and not unset them properly.
Søren Dyhr Posted April 20, 2009 Posted April 20, 2009 The elegance is, elsewhere than the US to use as less $ due to trade deficits ...joke aside, though wide scoped measures as global fields as well as variables should be dosed virtuously which means with hesitation: http://en.wikipedia.org/wiki/Global_variable ...so by nad large a bad habit! --sd
mr_vodka Posted April 20, 2009 Posted April 20, 2009 I agree with Michael here regarding global variables. That being said, perhaps you may want to take a look at these custom functions and see if you may benefit from adapting their methods. VariablesLog ( ) VariablesResetAll ( )
Lee Smith Posted April 20, 2009 Posted April 20, 2009 (edited) Can you explain why you need to clear these fields (or variables)? [color:red]Additional. Sorry, I didn't see your post where you state that you made errors in setting them. These now sound like normal fields with Global Storage? How many fields are involved? Have you read the Manual or checked out the Online Help on Globals Read about The Replace Function Loop Scripts Set Field Script Step Lee Edited April 20, 2009 by Guest Additional
jim0203 Posted April 20, 2009 Author Posted April 20, 2009 Thanks Lee, and everyone else who commented. I've now realised how and where to use Global variables in FM and will do so properly in my next project. For my current project (already beyond deadline) the custom functions will be really useful. I just need to clear everything down at certain points so that I know stray global variables aren't going to cause bugs. Thanks once again!
Recommended Posts
This topic is 5697 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now