More printf problems 2
- Posted by "Wallace B. Riley" <wryly at MINDSPRING.COM> Nov 10, 1997
- 845 views
--=====================_879189795==_ I tried to attach a message to a brief introduction a couple of minutes ago, and dropped the ball, so nothing was attached. Here we go again; I hope it works this time. Wally Riley wryly at mindspring.com --=====================_879189795==_ Hello everybody - Thanks to extensive help from Bob Pilkington and Ralf Nieuwenhuisen, my big program is running now, and it generates the 'progsig' outputs more or less satisfactorily.. It is a version of Art Adamson's traveling salesman program. I changed the 'progsig' interval so it is now generated every 10 minutes instead of every minute. Eventually I hope to remove it altogether. However, there is still something missing in my understanding of the 'printf' command, because I'm not getting any printed output at all. Ordinarily I wouldn't want much, but I do want enough at the present debugging stage to disclose any bugs. I'm left completely in the dark. I changed the program to work with a smaller collection of cities (18 instead of 48), which should produce some kind of output on the screen from time to time, and a printed message at longer intervals. I'm getting neither. I added a short routine that should print out a list of the cities in their current order at frequent intervals, whenever the program enters a particular subroutine, and I'm getting exactly nothing -- zero -- nada -- zilch. Here is the short routine: temp = open("PRN", "w") printf("temp", "%s\n", {"newTrip[1..9]}) printf("temp", "%s\n", {"newTrip[10..18]}) printf("temp", "%d\n\n", {count}) close("temp") The 18 states that should print out in two lines are, basically, the northeastern states of the U.S. plus all the states north of the Ohio River and east of the Mississippi River. Need a list? Here they are: ME, NH, VT, MA, RI, CT, NY, NJ, DE, MD, VA, WV, PA, OH, IN, MI, WI, IL. This is the initial order with which the main program begins; it should juggle the order, display any new order on the screen (now temporarily on the printer -- that doesn't work either) and if the new order has a shorter total distance, print that order on paper. The distance is the sum of the distances between the capitals of those states -- hence the resemblance of this program to the classic traveling-salesman problem. The object of the main program is to find a minimum-length tour (or almost minimum-length) of all 48 contiguous states of the U.S., subject to the restriction that each leg of the tour passes between adjoining states only. It is supposed to approximate the true minimum length only; the absolute minimum would take hundreds of years to compute. There are a number of other restrictions that follow from the adjoining requirement; I won't go into them now, because this is supposed to be a short note. There was an article about this project in the Amateur Scientist section of Scientific American last March. That article described an algorithm in C; Art Adamson revised the program in Euphoria and has recently produced an improved version, together with one from someone in Eastern Europe who doesn't know English, and whose program therefore I haven't yet been able to unravel. If you need additional information about this, some of it is available on the Euphoria Listserv (Art's two versions) or directly on the Internet (from the Society of Amateur Scientists). If I can help you by describing parts of it, let me know. If you really, *really* want to see my entire program, just ask; but it's a monster (eleven pages printed out) so I won't send it unless you absolutely, positively have to see it. My "short" version is also eleven pages, but it works with a smaller data base and is shorter in that respect only. Again, I'm reasonably sure that the hangup is in my use or misuse of the 'printf' command. There's something about it that I don't quite understand. I hope somebody can ferret it out. Thanks in advance. Wally Riley wryly at mindspring.com --=====================_879189795==_--