I had a function that worked for years. It seems that starting with DOORS 9.5, DXL started not passing a string parameter as a string unless I explicitly cast it as string or rename the function "trim" to something else like "trim1". The prior version was 9.3. Are there any new DXL built-in functions (aka PERMS) that could be causing a name clash? It is pretty easy to reproduce. See code below. Sample data output follows.
// Bug Demo Fu Lin Yiu - Wed Oct 16 15:04:51 EDT 2013 |
Re: function string trim(string) no longer works with V9.5 I don't have 9.5 so I this is a guess. I suspect there is a new "trim" function in 9.5 which has different parameter/return types. You are overloading the function, and the parser is picking the wrong one when you do not tell it the type. Search through the 9.5 %DOORSHOME%/lib/ folder. Maybe it is there someplace. -Adam |
Re: function string trim(string) no longer works with V9.5 Adamarla - Thu Oct 17 02:45:24 EDT 2013 I don't have 9.5 so I this is a guess. I suspect there is a new "trim" function in 9.5 which has different parameter/return types. You are overloading the function, and the parser is picking the wrong one when you do not tell it the type. Search through the 9.5 %DOORSHOME%/lib/ folder. Maybe it is there someplace. -Adam Good guess, but there are no functions in the %DOORSHOME%/lib/ sub-tree with name "trim" regardless of parameter lists or return type. Reading reveals there is no documented trim function recently introduced in the dxl reference manual. NOTE:
|
Re: function string trim(string) no longer works with V9.5 Adamarla - Thu Oct 17 02:45:24 EDT 2013 I don't have 9.5 so I this is a guess. I suspect there is a new "trim" function in 9.5 which has different parameter/return types. You are overloading the function, and the parser is picking the wrong one when you do not tell it the type. Search through the 9.5 %DOORSHOME%/lib/ folder. Maybe it is there someplace. -Adam You say it works when you declare "string myStr" but doesn't work when you don't? Yet another reason to turn autodeclare off. Adamarla has my guess, where "function" doesn't mean "perm" but some written function in the default loaded include files. Renaming the function to make it works strongly supports this guess. It is also possible, I suppose, that auto-declared "string"s are not quite right in v9.5 -Louie |
Re: function string trim(string) no longer works with V9.5 llandale - Thu Oct 17 14:08:57 EDT 2013 You say it works when you declare "string myStr" but doesn't work when you don't? Yet another reason to turn autodeclare off. Adamarla has my guess, where "function" doesn't mean "perm" but some written function in the default loaded include files. Renaming the function to make it works strongly supports this guess. It is also possible, I suppose, that auto-declared "string"s are not quite right in v9.5 -Louie Turning auto-declare off was on my checklist of things to do when there is a new release. DXL Reference says put it here. Still true? ********
In DXL there is a mechanism called auto-declare, which means that a user need not specify a type for a variable. For example, in the script: ******** Anything is possible with this silly putty of a language, but it appears auto-declare is disabled but it scews up the string parameter nevertheless. *** New simpler demo ***
// Bug Demo Rev A
/*
print "Original (set in $DOORSHOME/lib/dxl/startup.dxl) " //- XFLAGS_ &=~AutoDeclare_ ; // let's be sure print "Hammered-in (set above for fun) XFLAGS_ is " (XFLAGS_) "\n"
string trim(string s) {
string myStr1 = "bad"
print("original myStr1 is ~" (myStr1) "~" "\n");
print("original myStr2 is ~" (myStr2) "~" "\n");
// OUTPUT:
Original (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8 |
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Thu Oct 17 23:40:24 EDT 2013 Turning auto-declare off was on my checklist of things to do when there is a new release. DXL Reference says put it here. Still true? ********
In DXL there is a mechanism called auto-declare, which means that a user need not specify a type for a variable. For example, in the script: ******** Anything is possible with this silly putty of a language, but it appears auto-declare is disabled but it scews up the string parameter nevertheless. *** New simpler demo ***
// Bug Demo Rev A
/*
print "Original (set in $DOORSHOME/lib/dxl/startup.dxl) " //- XFLAGS_ &=~AutoDeclare_ ; // let's be sure print "Hammered-in (set above for fun) XFLAGS_ is " (XFLAGS_) "\n"
string trim(string s) {
string myStr1 = "bad"
print("original myStr1 is ~" (myStr1) "~" "\n");
print("original myStr2 is ~" (myStr2) "~" "\n");
// OUTPUT:
Original (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8 I always turn AutoDeclare off at the top of every script with:
That way you don't need to modify the client install, and if a script has turned it on(!), you have it off again :~/ -Adam |
Re: function string trim(string) no longer works with V9.5
Well, this works for me on 9.3.0.3 [I don't have 9.5]:
You don't need two trim functions.
One that takes references will take non references too and auto pass the address.
Maybe you need to explicitly Dereference the string in 9.5. Try uncommenting those lines...
-Adam
|
Re: function string trim(string) no longer works with V9.5 Adamarla - Fri Oct 18 01:59:47 EDT 2013
Well, this works for me on 9.3.0.3 [I don't have 9.5]:
You don't need two trim functions.
One that takes references will take non references too and auto pass the address.
Maybe you need to explicitly Dereference the string in 9.5. Try uncommenting those lines...
-Adam
I appreciate your reply.
Anyone have V9.5 that can give the samples a test drive (your car insurance may not cover it).???
|
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Fri Oct 18 03:48:21 EDT 2013 I appreciate your reply.
Anyone have V9.5 that can give the samples a test drive (your car insurance may not cover it).???
Ah, yes. That is true. A function expecting a reference will not take a literal so you will need a non reference version. But, why have a reference version anyway? String variables are already pointers to the string table, and strings are imutable anyway so when you modify it you get a new entry in the string table with a different pointer. Unless you want to return via byRef parameter and not the normal return type, just use a plain byVal string parameter. -Adam |
Re: function string trim(string) no longer works with V9.5 Adamarla - Fri Oct 18 01:34:21 EDT 2013 I always turn AutoDeclare off at the top of every script with:
That way you don't need to modify the client install, and if a script has turned it on(!), you have it off again :~/ -Adam Never include that statement in scripts! Realize that this statement is executed at "Parsing" time, but will become active only AFTER the current script has been executed. So if you first execute
And then execute:
You will see that this will run the first time and only on the second time yield an error! It is also clear, that you should never turn off autodeclare on a production system, because it might affect other scripts that made use of autodeclare (which you did not do). So turning off autodeclare is something that should be done only locally on the machine that you develop with. So incorporate it in your start link with -C if you do not want to modify your installation. Regards, Mathias |
Re: function string trim(string) no longer works with V9.5 Mathias Mamsch - Fri Oct 18 05:16:54 EDT 2013 Never include that statement in scripts! Realize that this statement is executed at "Parsing" time, but will become active only AFTER the current script has been executed. So if you first execute
And then execute:
You will see that this will run the first time and only on the second time yield an error! It is also clear, that you should never turn off autodeclare on a production system, because it might affect other scripts that made use of autodeclare (which you did not do). So turning off autodeclare is something that should be done only locally on the machine that you develop with. So incorporate it in your start link with -C if you do not want to modify your installation. Regards, Mathias Fair enough, I had never checked that. I have it turned off and expect it never to be turned on, but surely having it in scripts does no harm? Even if it has no effect on the current execution of the script, it is not screwing other stuff up right? -Adam |
Re: function string trim(string) no longer works with V9.5 Adamarla - Fri Oct 18 05:25:25 EDT 2013 Fair enough, I had never checked that. I have it turned off and expect it never to be turned on, but surely having it in scripts does no harm? Even if it has no effect on the current execution of the script, it is not screwing other stuff up right? -Adam It will screw up EVERY dxl script running in the current client, that does not respect the "declare all variables" development guideline, until you turn it on again (it applies to all DXL: DXL attributes, layouts, built in, foreign scripts, ...) But if you do :
You will not have any effect at all, because the autodeclare statements cancel themselfes at runtime and have NO effect on the current script, so its basically the same as
When you run it in an autodeclare enabled environment it will work, if you run it in an non autodeclared enabled environment the script will not even execute and the autodeclare statements will also not be executed. So as a correction of my prior statement: The autodeclare statement will be executed at runtime, but the current autodeclare setting will be checked at parse time (before execution), so that is why it has no effect on the current script. Regards, Mathias |
Re: function string trim(string) no longer works with V9.5 Mathias Mamsch - Fri Oct 18 06:28:34 EDT 2013 It will screw up EVERY dxl script running in the current client, that does not respect the "declare all variables" development guideline, until you turn it on again (it applies to all DXL: DXL attributes, layouts, built in, foreign scripts, ...) But if you do :
You will not have any effect at all, because the autodeclare statements cancel themselfes at runtime and have NO effect on the current script, so its basically the same as
When you run it in an autodeclare enabled environment it will work, if you run it in an non autodeclared enabled environment the script will not even execute and the autodeclare statements will also not be executed. So as a correction of my prior statement: The autodeclare statement will be executed at runtime, but the current autodeclare setting will be checked at parse time (before execution), so that is why it has no effect on the current script. Regards, Mathias Yeah, I get that, but I see it as fine because I want all scripts to fail if they rely on AutoDeclare. They would fail if you just turn it on once in StartUp anyway. [Sorry Fu Lin Yiu for going off topic] |
Re: function string trim(string) no longer works with V9.5
string test = "test string "
I ran the above code on 9.5 and it prints the following: -->test string<-- Running the above code on 9.3 results in the following:
-E- DXL: <Line:3> incorrectly concatenated tokens
So it indeed looks like 9.5 has declared trim as a new function somewhere. I ran a strings on the 9.5 doors.exe and I did not find any occurrence of the word "trim". |
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Fri Oct 18 03:48:21 EDT 2013 I appreciate your reply.
Anyone have V9.5 that can give the samples a test drive (your car insurance may not cover it).???
re: "But, why have a reference version anyway? String variables are already pointers to the string table, and strings are imutable anyway so when you modify it you get a new entry in the string table with a different pointer." I completely agree. The only purpose of making a function signature of "string trim(string&)" was a last ditch kludge to avoid having to rename trim() to something else in all my code. This would cover arguments that are string variables. Arguments that are in-line calls to functions that return a string still would not work. This is a mess. That is why I posted this issue. I want to get to the root of the problem and not add a bunch of kludge code to cover up the new undocumented behavior. Is there a new "string trim(string)" function in DXL V9.5? It is such a common need that it should have been in DXL all along. If so, I could comment out my trim code and go native. Is there any documentation indicating:
|
Re: function string trim(string) no longer works with V9.5 Adamarla - Fri Oct 18 07:27:17 EDT 2013 Yeah, I get that, but I see it as fine because I want all scripts to fail if they rely on AutoDeclare. They would fail if you just turn it on once in StartUp anyway. [Sorry Fu Lin Yiu for going off topic] I agree that all scripts <SHOULD> be written with AutoDeclare off; but many scripts <ARE NOT>. So if you routinely turn off AutoDeclare you will have difficulty running these other folks' sloppy scripts; which will be particularly relevant if they are attr-DXL, Layouts, or Triggers. But you can have your cake and eat it too. See attached. -Louie I wrote it in the steriotypically style of "Louie", rediculously verbose! Attachments AutoDeclare.dxl |
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Thu Oct 17 23:40:24 EDT 2013 Turning auto-declare off was on my checklist of things to do when there is a new release. DXL Reference says put it here. Still true? ********
In DXL there is a mechanism called auto-declare, which means that a user need not specify a type for a variable. For example, in the script: ******** Anything is possible with this silly putty of a language, but it appears auto-declare is disabled but it scews up the string parameter nevertheless. *** New simpler demo ***
// Bug Demo Rev A
/*
print "Original (set in $DOORSHOME/lib/dxl/startup.dxl) " //- XFLAGS_ &=~AutoDeclare_ ; // let's be sure print "Hammered-in (set above for fun) XFLAGS_ is " (XFLAGS_) "\n"
string trim(string s) {
string myStr1 = "bad"
print("original myStr1 is ~" (myStr1) "~" "\n");
print("original myStr2 is ~" (myStr2) "~" "\n");
// OUTPUT:
Original (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8 OK, so now I see you are casting myStr2 in the call to trim but not for myStr1. Thus, this is not an AutoDeclare issue.
I see no error in v9306, but that is what you said. I don't know. [1] Try staging results in a new variable, myStr3:
[2] Try separating the declare from the assignment:
-Louie |
Re: function string trim(string) no longer works with V9.5 GothSloth - Fri Oct 18 08:21:23 EDT 2013
string test = "test string "
I ran the above code on 9.5 and it prints the following: -->test string<-- Running the above code on 9.3 results in the following:
-E- DXL: <Line:3> incorrectly concatenated tokens
So it indeed looks like 9.5 has declared trim as a new function somewhere. I ran a strings on the 9.5 doors.exe and I did not find any occurrence of the word "trim". PARTIAL CONCLUSION: GothSloth is on to something. My further experiments reveal that there is a new (undocumented) perm out there. Apparently it has signature "void trim(string&)". Given this, the undocumented new DXL perm "void trim(string&)" will only work with variables because it takes a string reference. It won't work if you pass a function that returns a string. For example myStr = trim(upper(someVar)) won't work. Looks like we have an Unidentified Flying Perm (UFP) in V9.5
print "Original (set in $DOORSHOME/lib/dxl/startup.dxl) " //- XFLAGS_ &=~AutoDeclare_ ; // let's be sure print "Hammered-in (set above for fun) XFLAGS_ is " (XFLAGS_) "\n"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
print "Let's see if we find an address for signature void trim(string&)\n";
string test = " \t test string \t "
// Any usage of this sort will choke:
string trim(string s) {
print "Let's see if we find an address for signature string trim(string)\n";
string myStr1;
myStr1 = " from a variable "
myStr1 = " from a variable "
myStr1 = " from a variable "
// OUTPUT:
Original (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8
|
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Fri Oct 18 13:37:54 EDT 2013 PARTIAL CONCLUSION: GothSloth is on to something. My further experiments reveal that there is a new (undocumented) perm out there. Apparently it has signature "void trim(string&)". Given this, the undocumented new DXL perm "void trim(string&)" will only work with variables because it takes a string reference. It won't work if you pass a function that returns a string. For example myStr = trim(upper(someVar)) won't work. Looks like we have an Unidentified Flying Perm (UFP) in V9.5
print "Original (set in $DOORSHOME/lib/dxl/startup.dxl) " //- XFLAGS_ &=~AutoDeclare_ ; // let's be sure print "Hammered-in (set above for fun) XFLAGS_ is " (XFLAGS_) "\n"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
print "Let's see if we find an address for signature void trim(string&)\n";
string test = " \t test string \t "
// Any usage of this sort will choke:
string trim(string s) {
print "Let's see if we find an address for signature string trim(string)\n";
string myStr1;
myStr1 = " from a variable "
myStr1 = " from a variable "
myStr1 = " from a variable "
// OUTPUT:
Original (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8
The trim() function is not defined in the DOORS executable. It doesn't show up by running strings on the DOORS exe. I'm a little stumped about where it is coming from. I added the following code to <doors-root>/lib/dxl/init.dxl: string testString = "test string \n" // added at the top of the file trim( testString ); print "-->" testString "<--\n" //kept moving this line down the file until no error occured The encrypted DXL file standard/itemProperties/properties.dxl causes the function to become defined. I ran a DXL trace by calling startDXLTracing_() before the include of properties.dxl and calling stopDXLTracing() after the include. The word "trim" does not show up in the DXL trace. I've attached the trace in case anyone want's to look at it. Attachments dxltrace.txt |
Re: function string trim(string) no longer works with V9.5 GothSloth - Fri Oct 18 14:50:22 EDT 2013 The trim() function is not defined in the DOORS executable. It doesn't show up by running strings on the DOORS exe. I'm a little stumped about where it is coming from. I added the following code to <doors-root>/lib/dxl/init.dxl: string testString = "test string \n" // added at the top of the file trim( testString ); print "-->" testString "<--\n" //kept moving this line down the file until no error occured The encrypted DXL file standard/itemProperties/properties.dxl causes the function to become defined. I ran a DXL trace by calling startDXLTracing_() before the include of properties.dxl and calling stopDXLTracing() after the include. The word "trim" does not show up in the DXL trace. I've attached the trace in case anyone want's to look at it. GothSloth -- Thanks for looking into this. <IBM_Rant> It looks like the DOORS DXL trim function is in IBM's Area 51. Why all the secrecy for a simple trim function that exists in almost any programming language (or library)? I really wouldn't care except the introduction of this "top secret" feature is forcing me to rewrite code that has been working fine for years. Hey IBM, how about saying what it is and how it works? Is that too much to ask? If trim() is a proprietary secret, how about hiding it better so it does not break existing user's code? Add a few underscores to it at least. </IBM_Rant> |
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Fri Oct 18 16:04:33 EDT 2013 GothSloth -- Thanks for looking into this. <IBM_Rant> It looks like the DOORS DXL trim function is in IBM's Area 51. Why all the secrecy for a simple trim function that exists in almost any programming language (or library)? I really wouldn't care except the introduction of this "top secret" feature is forcing me to rewrite code that has been working fine for years. Hey IBM, how about saying what it is and how it works? Is that too much to ask? If trim() is a proprietary secret, how about hiding it better so it does not break existing user's code? Add a few underscores to it at least. </IBM_Rant> GothSloth & Fu Lin Yu: Which DOORS version do you exactly work with? I have DOORS 9.5.0.0 installed without any patches, and when I start a clean DOORS without any include directory parameters and registry settings, I cannot reproduce your problem.
string s1 = "hello blanks \n"
trim (s1)
print s1 "<-"
-E- DXL: <Line:2> incorrectly concatenated tokens
-E- DXL: <Line:2> undeclared variable (trim)
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.
|
Re: function string trim(string) no longer works with V9.5 Mike.Scharnow - Sat Oct 19 04:58:16 EDT 2013 GothSloth & Fu Lin Yu: Which DOORS version do you exactly work with? I have DOORS 9.5.0.0 installed without any patches, and when I start a clean DOORS without any include directory parameters and registry settings, I cannot reproduce your problem.
string s1 = "hello blanks \n"
trim (s1)
print s1 "<-"
-E- DXL: <Line:2> incorrectly concatenated tokens
-E- DXL: <Line:2> undeclared variable (trim)
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.
Thanks giving this matter a spin Mike.Scharnow. My client is:
Client version: 9.5.1.2 Results follow this simplified test code: // Do we have trim
/*
print "Auto-Declare setting (set in $DOORSHOME/lib/dxl/startup.dxl) " //-
//------------------------------------------------------------------------------
print "Let's see if we find an address for signature void trim(string&)\n";
string test = " \t test string \t " // RESULTS:
Auto-Declare setting (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8 |
Re: function string trim(string) no longer works with V9.5 Fu Lin Yiu - Sat Oct 19 12:10:45 EDT 2013 Thanks giving this matter a spin Mike.Scharnow. My client is:
Client version: 9.5.1.2 Results follow this simplified test code: // Do we have trim
/*
print "Auto-Declare setting (set in $DOORSHOME/lib/dxl/startup.dxl) " //-
//------------------------------------------------------------------------------
print "Let's see if we find an address for signature void trim(string&)\n";
string test = " \t test string \t " // RESULTS:
Auto-Declare setting (set in $DOORSHOME/lib/dxl/startup.dxl) XFLAGS_ is 8 I too am using 9.5.1.2 build 95088. |
Re: function string trim(string) no longer works with V9.5 GothSloth - Mon Oct 21 13:58:50 EDT 2013 I too am using 9.5.1.2 build 95088.
For kicks and giggles I wanted to see what was getting passed to the function "string trim(string sOrig)". I have this function interpret sOrig as a string and print the results. I also interpret sOrig as a pointer to a string and print the results. Here is the code: |
Re: function string trim(string) no longer works with V9.5 GothSloth - Mon Oct 21 18:28:02 EDT 2013
For kicks and giggles I wanted to see what was getting passed to the function "string trim(string sOrig)". I have this function interpret sOrig as a string and print the results. I also interpret sOrig as a pointer to a string and print the results. Here is the code: Can you translate all this VooDoo into something practical we can actually do to resolve it? Off the top of my head, I would be tempted to try this:
-Louie "VooDoo" because I really don't understand all this pointer/addr/reference stuff. lol |
Re: function string trim(string) no longer works with V9.5 llandale - Tue Oct 22 11:58:53 EDT 2013 Can you translate all this VooDoo into something practical we can actually do to resolve it? Off the top of my head, I would be tempted to try this:
-Louie "VooDoo" because I really don't understand all this pointer/addr/reference stuff. lol Well, the simplest wat to resolve it is to rename the custom function to something other than trim. Of course that is no good if you have baselined code... -Adam |
Re: function string trim(string) no longer works with V9.5 Adamarla - Wed Oct 23 02:31:26 EDT 2013 Well, the simplest wat to resolve it is to rename the custom function to something other than trim. Of course that is no good if you have baselined code... -Adam Louie, I agree with Adam. That would be a good approach. Type casting the parameters in calls to the locally defined trim function seem to work also. It looks like we have to modify our code to resolve this. I've opened a PMR requesting this function to be renamed trim_() to follow the convention used by other IBM DXL scripts. I'll let you know how it goes. |
Re: function string trim(string) no longer works with V9.5 GothSloth - Wed Oct 23 09:05:56 EDT 2013 Louie, I agree with Adam. That would be a good approach. Type casting the parameters in calls to the locally defined trim function seem to work also. It looks like we have to modify our code to resolve this. I've opened a PMR requesting this function to be renamed trim_() to follow the convention used by other IBM DXL scripts. I'll let you know how it goes. I am told this is now PM99549 and that it is due to be resolved in version 9.5.2.1. |
Re: function string trim(string) no longer works with V9.5 GothSloth - Thu Nov 21 15:59:30 EST 2013 I am told this is now PM99549 and that it is due to be resolved in version 9.5.2.1. Recently we upgraded to DOORS 9.6.1.8. I found that this http://www-01.ibm.com/support/docview.wss?uid=swg1PM99549 must have been implemented. Now it is safe to revert to user-defined trim functions with signature: string trim(string); // The typical signature for most programming languages In a test I found the undocumented perm void trim(&string); was replaced with undocumented perm void trim_(&string);
|