|
Daniel Beginner
Joined: 13 Oct 2000 Posts: 20 Location: Germany
|
Posted: Tue Mar 02, 2004 7:54 pm
%delitem is behaving very strange when embedded |
Hi, I have a small tak that I wanted to finish but I can't get that to work. The issue is that the delitem function is working perfectly when called stand alone, but when I call it embedded in my scripts it is going crazy.
Help is greatly appreciated and to motivate Zugg, some licenses pend on resolving this ;o)
Here are my settings as ASCII scrpits. use the alias 'reset' and then 'check_product' and you will see what I mean hopefully
Thanks,
Daniel
#CLASS {SlowWalk}
#CLASS 0
#ALIAS check_product_routine {#var check_flag 1;#forall @%1 {#show processed feature: %i;#if (%ismember( %i, @detected_features) & @check_flag) {} {#var check_flag 0}};#if (@check_flag) {#show @check_flag;#va processed_products %additem( %1, @processed_products);remove_detected_features_%1} {#show @check_flag}}
#ALIAS reset {#va detected_features "PWABA|SCBA|SCCA|SCAB|BRBA|PWABA";#va processed_products ""}
#ALIAS remove_detected_features_product_solid_old {#va detected_features %delitem( SCBA, @detected_features);#show @detected_features;#va detected_features %delitem( SCAB, @detected_features);#show @detected_features;#va detected_features %delitem( SCCA, @detected_features);#show @detected_features;#va detected_features %delitem( BRBA, @detected_features);#show @detected_features;#show removed solid_old}
#ALIAS remove_detected_features_product_pwa {#va detected_features %delitem( "PWABA", @detected_features);#show @detected_features;#show removed pwa}
#ALIAS check_product {#forall @available_products {#show processed product %i;check_product_routine %i};#if (%numitems( @detected_features)) {#show @detected_features;#wa 500;#yesno "Still features to process, check again?" {check_product} {#show CHECKING ABORTED}} {#show NO MORE FEATURES TO PROCESS}}
#VAR product_solid_old {SCBA|SCCA|BRBA|SCAB}
#VAR available_products {product_pwa|product_solid_old}
#VAR product_pwa {PWABA}
#VAR processed_products {}
#VAR detected_features {}
#VAR check_flag {1}
#VAR ToDo {}
#TRIGGER {({@product_solid_old|@product_pwa})} {#VAR detected_features %addItem( %1, @detected_features)} |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Mar 03, 2004 12:28 am |
Everything seems to be functioning fine to me. The only thing I can think of is that your trigger:
#TRIGGER {({@product_solid_old|@product_pwa})} {#VAR detected_features %addItem( %1, @detected_features)}
Is not behaving as you expect it to. |
|
|
|
Daniel Beginner
Joined: 13 Oct 2000 Posts: 20 Location: Germany
|
Posted: Wed Mar 03, 2004 12:00 pm |
Hi,
the trigger works like a charm, the troubles I have is in the delitem. I checked it with the 6.62 and 6.67 but both failed. I will download the 7.03 and try it with that version. Here my output when I make the 'reset' and 'check_product' and two YES:
processed product product_pwa
processed feature: PWABA
remove product_pwa
processed product product_solid_old
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
remove product_solid_old
PWABA|PWABA|SCBA|SCCA|BRBA|SCAB
processed product product_pwa
processed feature: PWABA
remove product_pwa
processed product product_solid_old
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
remove product_solid_old
PWABA|PWABA|PWABA|SCBA|SCCA|BRBA|SCAB
processed product product_pwa
processed feature: PWABA
remove product_pwa
processed product product_solid_old
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
remove product_solid_old
PWABA|PWABA|PWABA|PWABA|SCBA|SCCA|BRBA|SCAB
CHECKING ABORTED |
|
|
|
Pega Magician
Joined: 08 Jan 2001 Posts: 341 Location: Singapore
|
Posted: Wed Mar 03, 2004 2:54 pm |
Hi Daniel,
I agree with Vijilante.
Perhaps you made a mistake your the data, which made you think that delitem isn't working.
PWABA is duplicated in the your reset ALIAS.
#ALIAS reset {#va detected_features "PWABA|SCBA|SCCA|SCAB|BRBA|PWABA";#va processed_products ""}
On a side note, there is a difference between %delitem and #DelItem.
#DelItem removes all occurances of a string, whereas %delitem only removes the first occurance.
This is explicitly explained in the help file. It was always like this.
Cheerio. |
|
|
|
Daniel Beginner
Joined: 13 Oct 2000 Posts: 20 Location: Germany
|
Posted: Wed Mar 03, 2004 4:42 pm |
Hi,
as mentioned before the trigger works like a charm. I checked in on multiple licenses, I work in a software company and want to use ZMUD as a license checking tool. In such a license it can haben that features are multiple times available and then I want to get as output that two products were detected, what the routine would do. To avoid that a feature that was already detected is again detected I use %delitem(#delitem is not usable). But the %delitem is not working for me in the case and under the conditions I have currently. As mentioned I will check the issue again with the 7.03 once I can somehow download this thing .. our system is blocking for a $%##"?! reason.
Regards
Daniel |
|
|
|
Pega Magician
Joined: 08 Jan 2001 Posts: 341 Location: Singapore
|
Posted: Wed Mar 03, 2004 5:11 pm |
Well, you should specify what is expected behaviour.
As it stands all we have is,
1. a claim that %delitem doesn't work.
2. a chunk of source code which produces output consistent with expected %delitem behaviour.
I guess it all boils down to your algorithm. So, if you require some assistance with that, we would need at least an example of expected output.
Regards |
|
|
|
Daniel Beginner
Joined: 13 Oct 2000 Posts: 20 Location: Germany
|
Posted: Wed Mar 03, 2004 6:19 pm |
Hi,
I let a license file run through ZMUD and it detects all featurs that are present in the license file. Then I check the detected features against a number of reference products(here product_pwa, product_solid-old) and when I have the case that all features that are defining a product in the detectd_features variable I call the %additem to the proessed_products and the delitem on the detected_features to avoid that these features are detected again if I loop though the list again. This is then the final call, I detect if still some features are present in the detected_features and call again the routine.
The reset command just sets an example detected feature list and on purpose is in this list the item PWABA twice included, since this can also happen that the features of a product are twice in a license.
The issue that bugs me is that delitem is for me not deleting the features actually. So what I would expect in the end is a detected_features="". I checked my code, didn'T get it to work, slept over it and still couldn't get it to work. - Should I have produced buggy code - MEA CULPA - otherwise I was concluding it is a bug.
Regards
Daniel |
|
|
|
Pega Magician
Joined: 08 Jan 2001 Posts: 341 Location: Singapore
|
Posted: Wed Mar 03, 2004 7:43 pm |
My observation is that your trigger continues to fill your @detected features variable at every step of the way, this prevents %delitem from ever removing all the (elements) features in the list.
While %delitem removes each item from the left side of the list, %additem adds an item on the right side on the right side of the list. It is evidently consistent.
However, these lines are used to repopulate the list:
quote: processed feature: PWABA
...
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
...
PWABA|PWABA|SCBA|SCCA|BRBA|SCAB
...
processed feature: PWABA
...
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
The trigger fires once on this line too, 'PWABA|PWABA|SCBA|SCCA|BRBA|SCAB', on the first PWABA.
For expected results, perhaps you should change the trigger pattern to:
Code: |
#TRIGGER {^processed feature: ({@product_solid_old|@product_pwa})} {#VAR detected_features %addItem( %1, @detected_features)} |
I hope this helps. |
|
|
|
Septe Novice
Joined: 12 Oct 2000 Posts: 38 Location: USA
|
Posted: Wed Mar 03, 2004 9:46 pm |
Ok...I took your scripts and added #say Entering <routine name> at the beginning and #say Exiting <routine name> at the end of each alias. I ran the scripts by first running reset and then check_product. This is the results I got...
Entering check_product...
processed product product_pwa
Entering check_product_routine...
processed feature: PWABA
1
Entering remove_detected_features_product_pwa...farking long name
SCBA|SCCA|SCAB|BRBA|PWABA|PWABA
removed pwa
Exiting remove_detected_features_product_pwa...farking long name
Exiting check_product_routine...
processed product product_solid_old
Entering check_product_routine...
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
1
Entering remove_detected_features_product_solid_old...farking long name
SCCA|SCAB|BRBA|PWABA|PWABA|SCBA|SCBA|SCCA|BRBA|SCAB
SCCA|BRBA|PWABA|PWABA|SCBA|SCBA|SCCA|BRBA|SCAB|SCCA
BRBA|PWABA|PWABA|SCBA|SCBA|SCCA|BRBA|SCAB|SCCA|SCCA
PWABA|PWABA|SCBA|SCBA|SCCA|BRBA|SCAB|SCCA|SCCA|BRBA
removed solid_old
Exiting remove_detected_features_product_solid_old...farking long name
Exiting check_product_routine...
PWABA|PWABA|SCBA|SCBA|SCCA|BRBA|SCAB|SCCA|SCCA|BRBA|PWABA
CHECKING ABORTED
Exiting check_product...
I see a lot of items added to your lists and that's due to the trigger you had which does an additem everytime you did a #show <itemlist>. So what I did next is to disable the trigger....this is what I got...
Entering check_product...
processed product product_pwa
Entering check_product_routine...
processed feature: PWABA
1
Entering remove_detected_features_product_pwa...farking long name
SCBA|SCCA|SCAB|BRBA|PWABA
removed pwa
Exiting remove_detected_features_product_pwa...farking long name
Exiting check_product_routine...
processed product product_solid_old
Entering check_product_routine...
processed feature: SCBA
processed feature: SCCA
processed feature: BRBA
processed feature: SCAB
1
Entering remove_detected_features_product_solid_old...farking long name
SCCA|SCAB|BRBA|PWABA
SCCA|BRBA|PWABA
BRBA|PWABA
PWABA
removed solid_old
Exiting remove_detected_features_product_solid_old...farking long name
Exiting check_product_routine...
PWABA
CHECKING ABORTED
Exiting check_product...
Ok...much better. It does what you expect it to except for that last item, since you have two PWABAs, one at the beginning of the list and one at the end of the list.
The way your scripts are set up, you're only doing one of each type of product. It can't handle duplicated products unless you run it twice but if you check the variable processed_products, it'll show duplicates. The way to deal with that is to use #delitem which would cover all duplicates. To fix this script as I understand it, you need to do two things...get rid or disable the trigger (which as far as I can tell serves no purpose) and change %delitem to #delitem.
If this does not help, then you need to give us your expected results so we can compare the bad results with the expected results.
Septe |
|
|
|
Daniel Beginner
Joined: 13 Oct 2000 Posts: 20 Location: Germany
|
Posted: Thu Mar 04, 2004 1:10 pm |
Pega, Septe,
thank you for your help. I forgot to take the trigger into account on processing of the products.
If you come to Munich let me know, I spend you a beer ;o)
Regards
Daniel |
|
|
|
|
|