Skip to content

Instantly share code, notes, and snippets.

@sli
Created November 26, 2013 18:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sli/7663788 to your computer and use it in GitHub Desktop.
Save sli/7663788 to your computer and use it in GitHub Desktop.
C# port of my eJuice recipe parser.
using System;
using System.IO;
using System.Collections.Generic;
class eJuice
{
public int nicotine_base;
public int nicotine_target;
public int amount;
public int cut;
public int target_pg;
public int target_vg;
public int unknown_a;
public int unknown_b;
public int base_pg_percent;
public int base_vg_percent;
public int drops_per_ml;
public string notes;
public Flavor[] flavors;
private string[] recipe;
void eJuice(string fn)
{
recipe = File.ReadAllLines(fn);
nicotine_base = Convert.ToInt32(recipe[0]);
nicotine_target = Convert.ToInt32(recipe[1]);
amount = Convert.ToInt32(recipe[2]);
cut = Convert.ToInt32(recipe[3]);
target_pg = Convert.ToInt32(recipe[14]);
target_vg = Convert.ToInt32(recipe[15]);
unknown_a = Convert.ToInt32(recipe[16]);
unknown_b = Convert.ToInt32(recipe[17]);
base_pg_percent = Convert.ToInt32(recipe[18]);
base_vg_percent = Convert.ToInt32(recipe[19]);
drops_per_ml = Convert.ToInt32(recipe[30]);
notes = recipe[46];
flavors = new Flavor[7];
flavors[0] = new Flavor(recipe[9], recipe[4], recipe[20], recipe[25], recipe[31]);
flavors[1] = new Flavor(recipe[10], recipe[5], recipe[21], recipe[26], recipe[32]);
flavors[2] = new Flavor(recipe[11], recipe[6], recipe[22], recipe[27], recipe[33]);
flavors[3] = new Flavor(recipe[12], recipe[7], recipe[23], recipe[28], recipe[34]);
flavors[4] = new Flavor(recipe[13], recipe[8], recipe[24], recipe[25], recipe[35]);
flavors[5] = new Flavor(recipe[37], recipe[36], recipe[38], recipe[39], recipe[40]);
flavors[6] = new Flavor(recipe[42], recipe[41], recipe[43], recipe[44], recipe[45]);
}
}
class Flavor
{
public string name;
public int percent;
public int pg_percent;
public int vg_percent;
public bool flavorless;
public Flavor(string n, string p, string pgp, string vgp, string f)
{
name = n;
percent = Convert.ToInt32(p);
pg_percent = Convert.ToInt32(pgp);
vg_percent = Convert.ToInt32(vgp);
flavorless = Convert.ToBoolean(f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment