home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Linklist.prg
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 6/93
- *
- * UPDATED: 1/94
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: This program creates a simple linked list of integers
- * from 1 to 10. Each link in the chain is an instance of the
- * MyList class, which has 2 properties -- value, and next.
- * After the list is created, the function ShowList steps
- * through the list and shows all the links that have been
- * created.
- *
- * PARAMETERS: None
- *
- * CALLS: None
- *
- * USAGE: DO Linklist
- *
- *******************************************************************************
- * environment
- private saveLdCheck
- saveLdCheck = set("ldCheck")
- set ldCheck off
-
- * a simple xbase linked-list:
- private startList,link,i
-
- set talk off
- * beginning of the list
- startList = new MyList() && instantiation
- link = startList && link is a temporary reference for
- && stepping through the list
- for i = 1 to 10
- link.val = i
- if i < 10 && don't need an extra instance of the class
- link.next = new MyList() && create a new link
- link = link.next
- endif
- next
- do ShowList
-
- * restore environment
- set ldCheck &saveLdCheck
-
-
- * class definition for MyList
- *******************************************************************************
- class MyList
- *******************************************************************************
-
- this.val = 0
- this.next = 0
-
- endclass
-
-
-
-
- *******************************************************************************
- function ShowList
- * Displays the linked list created in the main program
- *******************************************************************************
-
- link = startList && start at the beginning of the list
- do while (.not. empty(link)) && go until no next link in list
- ? link.val
- link = link.next
- enddo
-
-
-
- **************************** End of Linklist.prg ******************************
-