Author Topic: Hash tables  (Read 5277 times)


  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Hash tables
« on: April 19, 2007, 10:42:56 pm »
I am just trying to use a hash table for the first time, and I am finding that there is a distinct lack of documentation about how they work.  How do you tell if a hash table lookup has failed?  What gets returned?

The following test macro displays 'x = PL/M' for the first call of messageNwait, but gives me an "Invalid argument" stack trace when trying to do the second messageNwait:

static _str test_hash_table:[] = {
   ''   => 'PL/M',
   ''    => 'pal'

_command void test() {
   _str x = test_hash_table:[''];
   messageNwait('x = ' :+ x);
   _str y = test_hash_table:['abc'];
   messageNwait('y = ' :+ y);


  • Senior Community Member
  • Posts: 2484
  • Hero Points: 325
Re: Hash tables
« Reply #1 on: April 20, 2007, 05:36:24 am »
Use _indexin before looking up the value.  _nextel can be used to traverse a hash table.  Try searching slick C source for _indexin to see examples of hashtable use.

Code: [Select]
int some_list :[];

void test()
    some_list:['a string'] = 1;
    if ( some_list._indexin('a string') )
        message('yes! a string is in the list');



  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: Hash tables
« Reply #2 on: April 22, 2007, 09:34:29 pm »
Graeme: Thank you, that was just the pointer I needed.

Note to whoever at SlickEdit is updating the documentation:

1) When you look up "Hash Tables" in the help index, the pointer currently goes to the wrong place on that help page (the bottom of the page), and you have to scroll up a bit to find the Hash Tables entry.

2) The entry on hash tables is all of just two lines of text and one syntax example!  Please, lots more here to show how to use them - they are a far too useful and powerful feature to miss using due to not being able to find out how.  At the very least, there must be cross-references to these:

  _el, _deleteel, _nextel, _makeempty, _isempty, _varformat, _indexin, _sort

3) Similarly, the entry on the same page for Arrays needs to cross-reference the above also (and any other relevant ones).


  • Senior Community Member
  • Posts: 2747
  • Hero Points: 289
Re: Hash tables
« Reply #3 on: April 22, 2007, 09:52:28 pm »
Lisa is responsible for 'SlickEdit Documentation' and would be surely happy getting such useful feedback directly:



  • Senior Community Member
  • Posts: 238
  • Hero Points: 24
  • User-friendly geek-speak translator extraordinaire
Re: Hash tables
« Reply #4 on: April 23, 2007, 01:40:18 pm »
Thanks Stephen! We are working on improving and updating the Slick-C Programming Guide, so this is a great time to get this kind of feedback.