SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: Bamsen on January 29, 2015, 07:55:31 am

Title: How to determine that an integer entry in a hash table is missing?
Post by: Bamsen on January 29, 2015, 07:55:31 am
This code is working for strings:
Code: [Select]
  _str Linjer:[];
  _str sTemp;
  if (Linjer:["OK"]._isempty()) { Linjer:["OK"]="1"; } else { Linjer:["OK"]=Linjer:["OK"] "1"; }
  if (Linjer:["OK"]._isempty()) { Linjer:["OK"]="2"; } else { Linjer:["OK"]=Linjer:["OK"] "2"; }
  for (sTemp._makeempty();;)
    {
    Linjer._nextel(sTemp);
    if (sTemp._isempty()) break;
    insert_line(sTemp " = " Linjer:[sTemp]);
    }

What I really want is for the hash to be of type integer so I can add each value.
But for the first one I can not check if the hash exist.
So if I have
Code: [Select]
  int Linjer:[];

How can I check if Linjer:["OK"] exists?

Thanks,
Morten
Title: Re: How to determine that an integer entry in a hash table is missing?
Post by: Bamsen on January 29, 2015, 08:00:18 am
After trying for days, of cause I find it right after posting.  ::)
Code: [Select]
if (Linjer:["OK"] == null) { Linjer:["OK"]=2; } else { Linjer:["OK"]+=2; }
Title: Re: How to determine that an integer entry in a hash table is missing?
Post by: Lee on January 29, 2015, 01:30:11 pm
Also take a look at the builtin _indexin() method:
Code: [Select]
typeless a:[];
a:['key1']=5;         // a._indexin('key1') will be true