Aug 22, 2013 at 10:57pm UTC
i need help with this code
exaple is input to the fuction (verc) is epspak 3.00.17
while it is isnside the fuction it converts correctly (coppak 8.00.03)
but when after the function is over i end up with epspak 8.00.03 or epspak 3.00.17 again :(
if i dont use a function for the conversion and have it straight on the main function it works fine.
please help
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
#include <windows.h>
#include <tchar.h>
using namespace std;
string version;
string app;
string filen;
string openr;
int numbe;
string don;
int don2;
void xferf (string app, string verson)
{
std::string b;
cout << "how many files?: " ;
cin >> numbe;
while (numbe > 0)
{
cout << "what is the compressed file name?: " ;
cin >> filen;
b = std::string("\\\\TPAJACOBL2W7\\archive\\xfer.bat " ) + app + std::string(" " ) + version + std::string(" " ) + filen;
system( b.c_str() );
--numbe;
}
}
void verc (string app, string version)
{
if (version == "3.00.03" ) //start version conversion//
{
app = "coppak" ;
version = "8.00.00" ;
}
if (version == "3.00.09" )
{
app = "coppak" ;
version = "8.00.01" ;
}
if (version == "3.00.14" )
{
app = "coppak" ;
version = "8.00.02" ;
}
if (version == "3.00.17" )
{
app = "coppak" ;
version = "8.00.03" ;
cout << app << version << endl;
}
if (version == "3.00.16" )
{
app = "cvxpak" ;
version = "8.00.11" ;
}
if (version == "1.66.16" )
{
app = "cvxpak" ;
version = "6.00.15" ;
}
if (version == "3.05.01" )
{
app = "cvxpak" ;
version = "7.00.02" ;
}
if (version == "3.05.02" )
{
app = "cvxpak" ;
version = "7.00.03" ;
}
if (version == "3.05.03" )
{
app = "cvxpak" ;
version = "7.00.04" ;
}
if (version == "3.05.04" )
{
app = "cvxpak" ;
version = "7.00.05" ;
}
if (version == "3.07.02" )
{
app = "hpspak" ;
version = "4.03.01" ;
}
if (version == "3.07.03" )
{
app = "hpspak" ;
version = "4.03.02" ;
}
if (version == "3.07.04" )
{
app = "hpspak" ;
version = "4.03.03" ;
}
cout << app << version << endl;
}
void clean ()
{
std::string c;
c = std::string("\\\\TPAJACOBL2W7\\archive\\clean.bat " );
system( c.c_str() );
system("cls" );
}
int done ()
{
cout << endl;
cout << "done with the dialin? (y/n): " ;
cin >> don;
if (don == "y" )
{
clean();
return 0;
}
if (don == "n" )
{
return 1;
}
}
int main(int argc, char *argv[])
{
SetConsoleTitle(_T("Tools by Jacob" ) );
//star();
while (true )
{
don2 = 1;
cout << "welcome to file xfer assistant" << endl;
cout << "please note this is case sensitve use lowercase" << endl;
cout << endl;
std::string s;
cout << "what software version is it?: " ;
cin >> app >> version;
if (app == "epspak" );
{
verc (app, version);
cout << app << " " << version << endl;
system ("pause" );
}
cout << "open the relsapp? (y/n): " ;
cin >> openr;
if (openr == "y" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\relsapp.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "buypak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "citpak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "coppak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "cvxpak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "hpspak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "shopak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
if ( app == "epspak" )
{
s = std::string("\\\\TPAJACOBL2W7\\archive\\shochk.bat " ) + app + std::string(" " ) + version;
system( s.c_str() );
}
cout << app << " " << version << endl;
system ("pause" );
xferf(app, version);
don2 = done();
}
system("PAUSE" );
return EXIT_SUCCESS;
} // end of main function
Last edited on Aug 23, 2013 at 12:33am UTC
Aug 22, 2013 at 11:33pm UTC
Pass by reference if you want the changes inside the function to be reflected outside of it.
Aug 23, 2013 at 2:47am UTC
thanks a bunch that worked
although i had to look up passing by reference cause im a noob lol
for any other noobs to pass by reference put an "&" symbol between your variable type and the variable name in the function declaration
example of that is
void verc (string app, string version) //non pass by refrance
void verc (string & app, string & version) // pass by refrance
Aug 23, 2013 at 4:49am UTC
Be careful not to overuse it though. There's an option between the two for a reason.