home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / SHMOD10.LHA / ShowModule / Modules / Pmodules / Plist / p_AjouteNode.e next >
Encoding:
Text File  |  1994-05-27  |  1.1 KB  |  32 lines

  1. PROC p_AjouteNode(ptr_list:PTR TO lh,node_name,adr) HANDLE /*"p_AjouteNode(ptr_list:PTR TO lh,node_name,adr)"*/
  2. /*===============================================================================
  3.  = Para         : address of list,the name of a node,adr to copy node if adr<>0.
  4.  = Return       : the number of the new selected node in the list.
  5.  = Description  : Add a node and return the new current node (for LISTVIEW_KIND).
  6.  ===============================================================================*/
  7.     DEF a_node:PTR TO ln
  8.     DEF nn=NIL
  9.     a_node:=New(SIZEOF ln)
  10.     a_node.succ:=0
  11.     a_node.name:=String(EstrLen(node_name))
  12.     StrCopy(a_node.name,node_name,ALL)
  13.     IF adr<>0  /* Copy the node in the structure) */
  14.         CopyMem(a_node,adr,SIZEOF ln)
  15.         AddTail(ptr_list,adr)
  16.         nn:=p_GetNumNode(ptr_list,adr)
  17.     ELSE
  18.         AddTail(ptr_list,a_node)
  19.         nn:=p_GetNumNode(ptr_list,a_node)
  20.     ENDIF
  21.     IF nn=-1
  22.         IF adr=0 THEN ptr_list.head:=a_node ELSE ptr_list.head:=adr
  23.         a_node.pred:=0
  24.         nn:=0
  25.     ENDIF
  26.     IF adr<>0 THEN Dispose(a_node) /* node is copied,free it */
  27.     Raise(nn)
  28. EXCEPT
  29.     RETURN exception
  30. ENDPROC
  31.  
  32.