TheNovice Posted April 30, 2020 Share Posted April 30, 2020 (edited) Hi, I have been using Daqfactory for quite a while now. Are there some changes lately? Today I was creating a simple new file to collect data and push it to sql server, and I noticed I am not able to run even simple function which I use to use previously. So I created a new file added a sequence(TempSeq) created a Temp Function as: Function TempFn() ?"abcd" Private string TempName = "ab" ?TempName EndFunction Apply, Compiled and saved the file.* When I try to run the function using command TempFn()/?TempFn() it say channel or function not found. The above same issue is happening with all my functions I am creating since yesterday. I am pretty much doing the same thing which we use to do always, but seems there is some weird problem since past couple days. Is there anything I am missing? Thanks! Edited April 30, 2020 by TheNovice Added content Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 30, 2020 Share Posted April 30, 2020 The function has to be the same name as the sequence unless it is contained in a class. Quote Link to comment Share on other sites More sharing options...
TheNovice Posted April 30, 2020 Author Share Posted April 30, 2020 Damn, never noticed that, but I had same name previously. Thanks. Also, I have had multiple functions inside the same sequence, and it has worked fine, any tips about naming sequence/function when having multiple function in same sequence? Thanks again. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 30, 2020 Share Posted April 30, 2020 Basically, the first function in a sequence, whether just script, or defined with "function" like you did, gets the name of the sequence, not the name specified in the "function" declaration. Any subsequent functions will keep their names and be global. This is actually an unintended "feature" that came out of compiling classes. So basically: sequence foo: // script a function xyz() // script b endfunction will create two functions, one named foo() that runs script a, and one named xyz that runs script b. Only script A will be executed if you do beginseq(foo), and you can't do beginseq(xyz). XYZ() can only be called as a function. Same goes here: sequence foo: function abc() // script a endfunction function xyz() // script b endfunction Even though you declared abc() as a function, since it is the first function in the sequence, it will get the name foo, not abc. Note that none of this applies in a class: sequence foo: class CMyClass function abc() //script a endfunction function xyz() // script b endfunction endclass Both abc() and xyz() are member functions of CMyClass. The name of the sequence is not used by the class itself. Of course a class declaration does nothing until it is instantiated using new(). So unlike my first examples, abc() and xyz() in CMyClass don't exist until CMyClass is instantiated, and then don't appear in the global namespace. Quote Link to comment Share on other sites More sharing options...
TheNovice Posted April 30, 2020 Author Share Posted April 30, 2020 Interesting and good to know! I'll keep that in mind now. Thank you so much for your help was banging my head since past 2 days, trying different things. Thanks again!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.