Files
harbour-core/harbour/samples/cccppc/defdict.prg
1999-11-09 01:37:27 +00:00

92 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* $Id$
*/
//*******************************************************************
// defdict.prg: #define sz¢t r
// 1999, Csisz r Levente
//*******************************************************************
#include "ctoken.ch"
#include "objgen.ch"
//*******************************************************************
#include "token.och"
#include "edefdict.och"
//*******************************************************************
#define _DEFDICT_PRG_
// #define _IMPLEMENT_ONEW_
#include "defdict.och"
//*******************************************************************
implement oinit()
super:oinit()
this:dict:={}
return nil
//*******************************************************************
implement add(edefdict)
local w
if (nil!=(w:=this:atKey(EDEFDICT.edefdict:name)))
return w
endif
aadd(this:dict,edefdict)
return nil
//*******************************************************************
implement atIdx(name)
local i
for i:=1 to len(this:dict)
if (name==EDEFDICT.(this:dict[i]):name)
return i
endif
end for
return 0
//*******************************************************************
implement atKey(name)
local i
if (0!=(i:=this:atIdx(name)))
return this:dict[i]
endif
return nil
//*******************************************************************
implement delKey(name)
local i
if (0!=(i:=this:atIdx(name)))
adel(this:dict,i)
asize(this:dict,len(this:dict)-1)
endif
return nil
//*******************************************************************
implement printStr(printBlock)
local i,w
local str:=""
for i:=1 to len(this:dict)
w:=toStr(i)+": "+EDEFDICT.(this:dict[i]):printStr()
if (printBlock!=nil)
eval(printBlock,w)
else
str+=w+newline()
endif
end for
return str
//*******************************************************************