Jump to a specific string of a list<string>

Pages: 12
Okay... What I have done so far..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
bool AYED2019::operaciones(vector<string> Original) {
	bool cond;
	int aux1 = 0, aux2 = 0, o2 = 0, o1 = 0, tempA = 0, tempB = 0;
	char auxiliar;
	int d = 0;
	char h, k, operacion;
	for (linea_actual = Script.begin(); linea_actual != Script.end(); linea_actual++) {
		string& cadena = *linea_actual;
		if (cadena.find("INT") == 0) {
				Entorno[cadena.at(4)];
		}
	}
	for (linea_actual = Script.begin(); linea_actual != Script.end(); linea_actual++) {
		string& cadena = *linea_actual;
		if (cadena.at(2) == '=') {
			for (iterador_mapa = Entorno.begin(); iterador_mapa != Entorno.end(); iterador_mapa++) {
				cout << "int: " << iterador_mapa->first << " " << "value: " << iterador_mapa->second;
				if (Entorno.find(cadena.at(0)) != Entorno.end() && isnumS(cadena.at(4))) {
					Entorno[cadena.at(0)] = atoi(&cadena.at(4));
				}
			}
		}
	}
	for (linea_actual = Script.begin(); linea_actual != Script.end(); linea_actual++) {
		iterador_mapa = Entorno.begin();
		string& chain = *linea_actual;
		if(chain.size()>6){
			if (chain.at(2) == '=') {
				if (Entorno.find(chain.at(4)) != Entorno.end()) {
					auxiliar = iterador_mapa->first;
					tempA = Entorno[chain.at(4)];
				}
				iterador_mapa++;
				if (isnumS(chain.at(8))) {
					tempB = atoi(&chain.at(8));
				}
				else {
					tempB = Entorno[chain.at(8)];
				}
				operacion = chain.at(6);
				calcular(tempA, tempB, operacion);
				Entorno[chain.at(4)] = calcular(tempA, tempB, operacion);
			}
		}
	}
	for (linea_actual = Script.begin(); linea_actual != Script.end(); linea_actual++) {
		iterador_mapa = Entorno.begin();
		string& cadena = *linea_actual;
		if (cadena.at(0) == 'I' && cadena.at(1) == 'F') {
			size_t pos1 = cadena.find("IF");
			string str1 = cadena.substr(pos1);
			for (iterador_mapa = Entorno.begin(); iterador_mapa != Entorno.end(); iterador_mapa++) {
				if (Entorno.find(cadena.at(5)) != Entorno.end()) {
					o1 = Entorno[cadena.at(5)];
					//	cout << "El valor de o1 es: " << o1 << endl;
					aux1 = 1;
					iterador_mapa++;
					if (Entorno.find(cadena.at(9)) != Entorno.end()) {
						o2 = Entorno[cadena.at(9)];
						//		cout << "El valor de o2 es: " << o2 << endl;
						aux2 = 1;
					}
					else {
						o2 = atoi(&str1.at(9));
						//		cout << "El valor de o2 es: " << o2 << endl;
						aux2 = 1;
					}
					if (aux1 == 1 && aux2 == 1) {
						h = str1.at(7);
						condicionIfElse(h, o1, o2);
						break;
					}
				}
			}
			if (condicionchequeada == true) {
				if (size_t pos = cadena.find("THEN")) {
					string str3 = cadena.substr(pos);
					//iterador_mapa = Entorno.begin();
					if (str3.find("SHOW")) {
						for (int i = 0; i < str3.size(); i++) {
							if (Entorno.find(cadena.at(5)) != Entorno.end()) {
								cout << "Showing: " << Entorno[cadena.at(5)] << endl;
								break;
							}
						}
					}
					if (str3.find("JUMP")) {

					}
				}
			}
		}
	}

	for (linea_actual = Script.begin(); linea_actual != Script.end(); linea_actual++) {
		iterador_mapa = Entorno.begin();
		string& cadena = *linea_actual;
		if (cadena.at(0) == 'S' && cadena.at(1) == 'H' && cadena.at(2) == 'O' && cadena.at(3) == 'W') {
			if ((iterador_mapa = Entorno.find(cadena.at(5))) != Entorno.end()) {
				cout << "El valor de: " << iterador_mapa->first << " es: " << iterador_mapa->second << endl;
			}
		}
	}

	for (linea_actual = Script.begin(); linea_actual != Script.end(); linea_actual++) {
		iterador_mapa = Entorno.begin();
		string& cadena = *linea_actual;
		if (cadena.at(0) == 'J' && cadena.at(1) == 'U' && cadena.at(2) == 'M' && cadena.at(3) == 'P') {
			if (isnumS(cadena.at(5))) {
				linea_actual = Script.begin();
				d = atoi(&cadena.at(5));
				for (int i = 0; i < d - 1; i++) {
					linea_actual++;
				}
			}
			break;
		}
	}
	for (iterador_mapa = Entorno.begin(); iterador_mapa != Entorno.end(); iterador_mapa++) {
		cout << " " << iterador_mapa->first << " : " << iterador_mapa->second << endl;
	}
	//cout << "Aux: " << auxiliar << " Int: " << tempA << endl;
}
I know it might not be the best or optima way to do this but its the easiest way for me to see it. Im still struggling to get the JUMP, and IF THEN part, but i think the rest is good
Topic archived. No new replies allowed.
Pages: 12