Results of constant __FILE__ depends on place of usage

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
3 posts • Page 1 of 1
flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

Results of constant __FILE__ depends on place of usage

Post by flindecke »

Installation: WinCC OA 3.14

The described behavior is also found in WinCC OA 3.13 (already tested by consultant)

Documentation of __FILE__ explains
"During run-time, the constant is replaced with the name of the file (or library) in which the constant is called."

But this is only valid, when __FILE__ is used in a library function. When function (which uses __FILE__) is in scopelib or in a handler of a button following information is returned.

Function in Button Clicked handler
"[Module: _QuickTest_ Panel: examples\\\\gridLayout.pnl Object: PUSH_BUTTON4 Script: Clicked]"

Function in Scopelib:
"[Module: _QuickTest_ Panel: examples\\\\gridLayout.pnl ScopeLib: gridLayout.pnl]"


What i have wanted to solve:
Panels should be "moveable" between directories. When using "addSymbol" and the panels to be added are in the same directory like the panel itself, they need the full path name (from panels directory) to be used in addSymbol API.
So i wanted to use something like dirName(__FILE__) + "myOtherPanel". But this only works, when this call is placed in a control library and not in scopelib or handler of button.

Note: In my opinion this behavior is surprising and should be fixed. Perhaps it is better to implement another constant like __FILENAME__ which always returns the file name only (without the additional information).

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: Results of constant __FILE__ depends on place of usage

Post by leoknipp »

I've tested it but I could not find the problem you have tried to describe.
The information gives the information for the script where the constant __FILE__ is used.

Can you please describe it more exactly, maybe you can add an example where the problem can be seen.

Best Regards
Leopold Knipp
Senior Support Specialist

flindecke
Posts:69
Joined: Wed Jun 24, 2015 1:54 pm

Re: Results of constant __FILE__ depends on place of usage

Post by flindecke »

See attached file and open panel FileConstantTest.xml.

I expect just the name of the file, event for the name of the panel, but i get the module and script name as well. As a consequence i have to parse the __FILE__ constant in a panel file.

3 posts • Page 1 of 1