Talk:Storage Slip Reverse Lookup

As noted on the page, I created the page source with a small C# program. I also had to dump all of the contents of each Moogle Storage Slip ## page into a text file which the program parses. So if/when more storage slips are added to the wiki, this page will need to be regenerated. The program simply requires the mentioned text file to be in the run directory (usually either bin/Debug or bin/Release). The output file will be created there. Just open it and copy the contents into the wiki page's source editor.

The following can be put in the "Program.cs" file of a fresh C# project and run.

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions;

namespace WikiStorageSlipParser {   class Program {       static void Main(string[] args) {           String inputFile = "Storage Slip Source.txt"; String outputFileName = "Item to Storage Slip Table.txt"; String inputFileAbsPath = Directory.GetCurrentDirectory + "\\" + inputFile; if (!File.Exists(inputFileAbsPath)) {               Console.WriteLine("Error!!! Could not find input file. Exiting..."); return; }           StreamReader fileReader = new StreamReader(inputFileAbsPath); StreamWriter outputFile = new StreamWriter(outputFileName); Byte slipNb = 0; String slipNbExpression = "[Mm]oogle [Ss]torage [Ss]lip ([0-9][0-9])"; bool lookingForSlipNb = true; String storesExpression = "==Stores=="; bool lookingForStores = true; String endExpression = "\\|}"; String itemExpression = ".*\\[\\[(.*)\\]\\].*"; SortedDictionary itemToSlipNbMap = new SortedDictionary; while (!fileReader.EndOfStream) {               String line = fileReader.ReadLine; if (lookingForSlipNb) {                   Regex regex1 = new Regex(slipNbExpression); Match match1; try {                       match1 = regex1.Match(line); if (!match1.Success) {                           continue; }                       else {                           slipNb = Byte.Parse(match1.Groups[1].ToString); lookingForSlipNb = false; continue; }                   }                    catch (Exception e)                    { Console.WriteLine("Error while trying to parse slip number: " + e.ToString); return; }               }                else if (lookingForStores) {                   Regex regex1 = new Regex(storesExpression); Match match1; try {                       match1 = regex1.Match(line); if (!match1.Success) {                           continue; }                       else {                           lookingForStores = false; continue; }                   }                    catch (Exception e)                    { Console.WriteLine("Error while trying to parse ==stores== : " + e.ToString); return; }               }                else {                   Regex regex1 = new Regex(endExpression); Match match1; try {                       match1 = regex1.Match(line); if (!match1.Success) {                           //Check for an item. Regex regex2 = new Regex(itemExpression); Match match2; try {                               match2 = regex2.Match(line); if (match2.Success) {                                   itemToSlipNbMap.Add(match2.Groups[1].ToString, slipNb); }                           }                            catch (Exception e)                            { Console.WriteLine("Error while trying to parse an item: " + e.ToString); }                       }                        else {                           lookingForSlipNb = true; lookingForStores = true; continue; }                   }                    catch (Exception e)                    { Console.WriteLine("Error while trying to parse the stores table: " + e.ToString); return; }               }            }            if (itemToSlipNbMap.Count > 0) {               Console.WriteLine("Number items found: " + itemToSlipNbMap.Count); Byte lastSlipNb = 0; String colorEven = "|- BGCOLOR=\"#e3e6ff\""; String colorOdd = "|- BGCOLOR=\"#ffffff\""; String colorHdr = "|- BGCOLOR=\"#ffdead\""; bool even = false; // Print the page header (above the table) outputFile.WriteLine(""); outputFile.WriteLine("==Summary=="); outputFile.WriteLine("This page is simply a reverse lookup for storable items (via the porter moogle)."); outputFile.WriteLine("The page was auto-generated with a C# program. See the talk page for the program and instructions. "); outputFile.WriteLine("==Storable Items=="); outputFile.WriteLine(":{| width\"100% cellpadding=\"2\" cellspacing=\"2\"");               outputFile.WriteLine(colorHdr);                outputFile.WriteLine("!width=\"50%\"|Item");                outputFile.WriteLine("!width=\"50%\"|Slip #");                // Print all of the storable items                foreach (KeyValuePair kvp in itemToSlipNbMap)                {                    if (lastSlipNb != kvp.Value)                    {                        // This will alternate the background color of the rows if the                        // storage slip number changes. In other words it will group                        // consecutive items together if they are stored with the same slip.                        even = !even;                    }                    if (even)                    {                        outputFile.WriteLine(colorEven); }                   else {                       outputFile.WriteLine(colorOdd); }                   lastSlipNb = kvp.Value; String oLine = "!width=\"50%\"|" + kvp.Key + ""; outputFile.WriteLine(oLine); oLine = "!width=\"50%\"|Moogle Storage Slip " + kvp.Value.ToString("D2") + ""; outputFile.WriteLine(oLine); }               // Close the table outputFile.WriteLine("|}"); outputFile.Close; }           else {               Console.WriteLine("Map was empty."); }           fileReader.Close; }   } }