Author Topic: How to determine that an integer entry in a hash table is missing?  (Read 885 times)

Bamsen

  • Community Member
  • Posts: 41
  • Hero Points: 1
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

Bamsen

  • Community Member
  • Posts: 41
  • Hero Points: 1
Re: How to determine that an integer entry in a hash table is missing?
« Reply #1 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; }

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1092
  • Hero Points: 94
Re: How to determine that an integer entry in a hash table is missing?
« Reply #2 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