Submitted by ajr on 2010/01/29 23:27
 I have a number field (TradeLongCount) that is either a 1 or a zero.  It takes a Boolean field's value and multiplies it by -1.  The goal is that as I click the yes/no box, an icon will be added and then removed from the item field.  Here's what I've tried in the Auto Assign Rules of the TradeLongCount field:
 
A:Item=AddKeyword(Item,"<img>arrow_up</img>")|E:Item=RemoveKeyword(Item,"<img>arrow_up</img>")
 
This has no effect on the item field.
 
Then I tried:
 
M:Item=if TradeLongCount=1 then AddKeyword(Item,"<img>arrow_up</img>") elseif TradeLongCount=0 then RemoveKeyword(Item,"<img>arrow_up</img>")
 
This will completely empty the existing text in the Item field at the first click, not adding the icon.  I've also written the above logic as an iif with the same result.
 
I know this forum isn't about VBscript but the first attempt is very similar to both the forum post on automating wiki assignments, referenced in Section 4 of the manual and the page on icon assignments.  I'm having a tough time figuring out why I'm not getting the expected result.  Does it have to do with the number field?  I've also tried >0.9 and <0.1 in case there was a problem with a floating decimal.  It didn't make any difference.  Neither did turning "Null Values=0" on and off.
 
P.S. Pierre - thank you for the advice on file size.  I've also opened a number of pdfs in the html pane and saved them so they would be indexed.  Could that also be a major contributor to the file's size?

Comments

 
I havent used icons myself so cant really comment. This from Armando may help though -- link to nonexistent node ID 738 --
 

Hi ajr,
 
[quote=ajr]
 I have a number field (TradeLongCount) that is either a 1 or a zero.  It takes a Boolean field's value and multiplies it by -1.  The goal is that as I click the yes/no box, an icon will be added and then removed from the item field.
[/quote]
 
Just to make sure :
 
1- How is this multiplication taking place exactly, and why do you need it ? (This could be the problem, but I'm not sure exactly how these operations are performed.)
 
You seem to know what you're doing but :
 
2- Is TradeLongCount a Boolean field it self (with a check box) or a numeric field ? 
 
 
[quote=ajr]
Here's what I've tried in the Auto Assign Rules of the TradeLongCount field:
 
A:Item=AddKeyword(Item,"<img>arrow_up</img>")|E:Item=RemoveKeyword(Item,"<img>arrow_up</img>")
 
This has no effect on the item field.
 
Then I tried:
 
M:Item=if TradeLongCount=1 then AddKeyword(Item,"<img>arrow_up</img>") elseif TradeLongCount=0 then RemoveKeyword(Item,"<img>arrow_up</img>")
 
This will completely empty the existing text in the Item field at the first click, not adding the icon.  I've also written the above logic as an iif with the same result.
[/quote]
 
 
Reading this, I imagine that you read the manual. I don't see why this wouldn't work :
 
A:Item=AddKeyword(Item,"<img>arrow_up</img>")|E:Item=RemoveKeyword(Item,"<img>arrow_up</img>")
 
I tried it myself and it works -- but I chose another icon name.
 
What I'd suggest :
 
- Check the first 2 questions I asked before.... Who knows.
 
- Make sure that
1- the icon you chose is in IQ's "icons" folder (in the main folder),
2- and that you've restarted IQ. IQ loads all icons when starting.
 
Don't put too many icons there as it will slow down IQ considerably and completely clog your GDI resources. IQ already tends to consume a lot of these when several grids, gantt charts, tables etc. are opened.
 
[quote=ajr]
I know this forum isn't about VBscript but the first attempt is very similar to both the forum post on automating wiki assignments, referenced in Section 4 of the manual and the page on icon assignments.  I'm having a tough time figuring out why I'm not getting the expected result.  Does it have to do with the number field?  I've also tried >0.9 and <0.1 in case there was a problem with a floating decimal.  It didn't make any difference.  Neither did turning "Null Values=0" on and off.
 [/quote]
 
Not sure I understand this part of your question. I'll have to check the posts you're referring to.
 
 
[quote=ajr]
 
P.S. Pierre - thank you for the advice on file size.  I've also opened a number of pdfs in the html pane and saved them so they would be indexed.  Could that also be a major contributor to the file's size?
 
[/quote]
 
By the "file's size", you mean the actual DB size on your Hard Drive ? Your documents would have to be huge to really make the DB big.
 
How many MB ? And how big are the files you saved ?
 
You could also tried compacting the DB. Options -> Database management --> compact.

Armando

2010/01/30 15:28

In reply to by Armando

Small edit...
I wouldn't use the "A:" for your first Icon auto assign equation. I'd use AM: (Add or modified), since your field seems to be one that's prone to modification, not just add/remove. But maybe it's unecessary if you decided that null=0 for this field... You decide.
 
AM:Item=AddKeyword(Item,"<img>arrow_up</img>")|E:Item=RemoveKeyword(Item,"<img>arrow_up</img>")

ajr

2010/01/30 17:51

In reply to by Armando

Hi Armando,
 
Thanks for the reply.  TradeLongCount is a number field.  I saw your note in the 10.95 page that a large number of icons hurts IQ's performance, and I took all the icons out except for four.  IQ has been restarted since changing the contents of the Icon folder.
 
I'm afraid I'm going to have to bore you with some of the details of my database.  This is a trade log, where a trade can be either to the short side or the long side, the checkbox says which it is.  In addition, I want a parent item of the trades to count the number of long and short trades.
 
So, the basic idea is I have one Yes / No checkbox (TradeWasLong), followed by two number fields (TradeLongCount and TradeShortCount) which are either a 1 or 0, and a parent item (something like Trades in June 2008) which sums TradeLongCount and TradeShortCount.
 
Since TradeWasLong is a boolean field, my row equation for TradeLongCount is '=(TradeWasLong)*-1' and the row equation for TradeShortCount is '=(TradeWasLong)+1'.
 
Here's the way I envisioned it working:
 
TradeWasLong TradeLongCount TradeShortCount
blank empty empty empty
click once check (-1) +1 0 up arrow icon added
click twice blank (0) 0 +1 up arrow icon removed
click thrice - same as once and so on
 
I realized while typing this that I hadn't tried it on a brand new item in a few days, so I created some new items and changed the rules a few times to see if it changed anything.  Results:
 
As in original post with A:~|E:~, first click added up arrow and down arrow.  Subsequent clicks had no effect on the Item field.
 
As per your suggestion with AM:~|E:~, same result as with A;~|E:~.  I tried this with null value = 0 set to on and off.
 
Then I tried it with the longer modification push rule.  The first click had no effect, the second click wiped out the item text and further clicks had no effect.  Again I did this on new items, with the null value=0 option set to on and off.
 
The section of my  first post that was unclear had to do with my trying to get the longer Modification rule to work.  
 
    [M:Item=if TradeLongCount=1 then AddKeyword(Item,"<img>arrow_up</img>") elseif TradeLongCount=0 then RemoveKeyword(Item,"<img>arrow_up</img>")]
 
I had noticed in the Properties pane that a number field, which was the difference to the subtraction of two five decimal numbers, had a value of 3.106000000000001E-02.  So I figured there was a possibility of a floating decimal error, and that instead of writing 'TradeLongCount=1' it would be a better idea to write 'TradeLongCount>0.9'.  In writing this I think I've come to see at least part of the problem.  The rules for the down arrow are similar to those for the up arrow.  The intent had been for it to appear when I clicked twice, and TradeShortCount=1, and if needed removed on the third click.   However, the rule was to add the arrow when a value was added to the field. and at the first click the value went from empty to zero.  It's also clear now why the icons never leave, the value in the number field is either 1 or 0, never empty.  Not sure how I'm going to fix it, but it's going to have to be a Modification rule.
 
As for the file size, my IQBase is 26 MB and Pierre had mentioned that it would likely be smaller if I worked on the html pane content in BlockNote instead of MS Word, and I was curious if the pdf content that I've opened and saved in the HTML pane made a big difference in the file size.

Armando

2010/01/30 18:43

In reply to by ajr

Nice stuff, ajr.
I'll have to try your exact same config later.
 
My guess is that this won't work, as "E:..."  won't have any effect with a 0 value -- that is if you put your equations in the TradeLongCount equation section. 0 doesn't equal null. I haven't tried it with the null=0 spec. but I don't think it applies to auto assign rules...
Haven't tested it though. Might do it later.
 
However, it should work if you put your "equations" :
 
A:Item=AddKeyword(Item,"<img>arrow_up</img>")|E:Item=RemoveKeyword(Item,"<img>arrow_up</img>")
 
in the TradeWasLong (Boolean field) equation section instead (from what I read, it should achieve the same thing -- correct me if I'm wrong)
 
 
Otherwise, you could try to do it with a VB script you'd add in the "User Code" section, or "This Database". If you need indication, I'll provide some.

ajr

2010/02/05 04:06

In reply to by Armando

 I could never get the auto assign rules to work the way I wanted with number fields.  The goal was to click or double click one box, and then have an up or down arrow added to the item text.  I felt pretty sure that I could get it to work with a yes/no field like in the example you posted above, and one obvious work around was to have two different check boxes, one if its a long trade another if its a short.  But I was reluctant since it seemed a little clunky.  After all long and short are mutually exclusive, so clicking one checkbox should do it...
 
I swear it took me days to realize that I could create two new checkboxes, call them TradeLongIcon and TradeShortIcon, have them equal TradeLongCount and TradeShortCount times negative one, use the auto assign rules as listed above, and that would be it - goal met.  Sometimes the simplest things...

Armando

2010/02/05 11:38

In reply to by ajr

[quote=ajr]
 I could never get the auto assign rules to work the way I wanted with number fields.  The goal was to click or double click one box, and then have an up or down arrow added to the item text.  I felt pretty sure that I could get it to work with a yes/no field like in the example you posted above, and one obvious work around was to have two different check boxes, one if its a long trade another if its a short.  But I was reluctant since it seemed a little clunky.  After all long and short are mutually exclusive, so clicking one checkbox should do it...
 
I swear it took me days to realize that I could create two new checkboxes, call them TradeLongIcon and TradeShortIcon, have them equal TradeLongCount and TradeShortCount times negative one, use the auto assign rules as listed above, and that would be it - goal met.  Sometimes the simplest things...
[/quote]
 
Good to hear that you finally got what you want... (Well I hope you did !)
Don't hesitate to ask more questions.

Armando

2010/01/30 18:49

In reply to by ajr

[quote=ajr]
I had noticed in the Properties pane that a number field, which was the difference to the subtraction of two five decimal numbers, had a value of 3.106000000000001E-02.  So I figured there was a possibility of a floating decimal error, and that instead of writing 'TradeLongCount=1' it would be a better idea to write 'TradeLongCount>0.9'.  In writing this I think I've come to see at least part of the problem.  The rules for the down arrow are similar to those for the up arrow.  The intent had been for it to appear when I clicked twice, and TradeShortCount=1, and if needed removed on the third click.   However, the rule was to add the arrow when a value was added to the field. and at the first click the value went from empty to zero.  It's also clear now why the icons never leave, the value in the number field is either 1 or 0, never empty.  Not sure how I'm going to fix it, but it's going to have to be a Modification rule.
 
As for the file size, my IQBase is 26 MB and Pierre had mentioned that it would likely be smaller if I worked on the html pane content in BlockNote instead of MS Word, and I was curious if the pdf content that I've opened and saved in the HTML pane made a big difference in the file size.
[/quote]
 
Forgot that part...
 
- About the floating decimal error... Pierre will have to look at it. Can you provide the steps to reproduce this ?
 
- File size : Did you compact ? you could also open the scratch grid, display the itemHTMLsize field in the grid, clean all filters in the source bar (alt-s, etc.), refresh, and sort by itemHTMLsiz, and see which items are using the most space. Numbers are in bytes if I'm not mistaken...
 
Then, you could try saving your text using different means, and see if it makes a difference.

Thanks for sending the file. I was able to reproduce the issue and provide a fix.
 
This is a classical rounding error problem. Try this.
  1. In notepad, enter:
    Dim myvar
    myvar = 5.35 - 5.45
    WScript.Echo myvar
  2. Save it as testvb.vbs
  3. double-click on the file
  4. It will return -0.10000000000001
I now provide some built-in rounding