Advertisement
kolpastebin

List locations by zone.ash

Jul 15th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. boolean setting_output_for_spreadsheet = false;
  2.  
  3. location [int] listMakeBlankLocation()
  4. {
  5. location [int] result;
  6. return result;
  7. }
  8.  
  9.  
  10. void listAppend(location [int] list, location entry)
  11. {
  12. int position = count(list);
  13. while (list contains position)
  14. position = position + 1;
  15. list[position] = entry;
  16. }
  17.  
  18.  
  19. void main()
  20. {
  21. location [string][int] locations_by_zone;
  22.  
  23. foreach loc in $locations[]
  24. {
  25. if (!(locations_by_zone contains (loc.zone)))
  26. locations_by_zone[loc.zone] = listMakeBlankLocation();
  27. locations_by_zone[loc.zone].listAppend(loc);
  28. }
  29. foreach zone in locations_by_zone
  30. {
  31. boolean first = true;
  32. if (!setting_output_for_spreadsheet)
  33. print(zone + ":");
  34. foreach key in locations_by_zone[zone]
  35. {
  36. location loc = locations_by_zone[zone][key];
  37. if (first && setting_output_for_spreadsheet)
  38. {
  39. print(zone + "      " + loc);
  40. first = false;
  41. }
  42. else
  43. print("      " + loc);
  44. }
  45. }
  46.  
  47. print("done");
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement