Skip to main content

Button doesn't evaluate variable containing Module


I have a huge set of code to accomplish a data transformation. I have saved this set of code as eg:


 codeset:=Module[{},

FileNameSetter[Dynamic[Tab2excelFileLocation]];
RawDataTonnages =Import[Tab2excelFileLocation, {"Sheets", "Tonnages"}];
(*...blah blah blah...data transformation and setting up graphs and stats tables...*)
FileNameSetter[Dynamic[Tab3excelFileLocation]];
Tab3RawDataTonnages =Import[Tab3excelFileLocation, {"Sheets", "Tonnages"}]
(*...blah blah blah....data transformation and setting up graphs and stats tables...*)
];
Button["Recalculate", codeset]

Later I want to use the two FileNameSetter buttons to locate new files. Once this has been done I then want to press the Recalculate button to re-evaluate 'codeset' so that my answers reflect the data from the new files.



I have get this to work partially - when I press the button the codeset re-evaluates for the 1st filename setter only even though I have changed both. If I test not by using the button but by re-evaluating the code using shift+enter it works for both filename setters. Why is this happening, I can't understand it.




Comments