|
Hey, can you please help me with this task...
I want to code a replacement list for variables. This list should be stored in a simple text file or in an simple TextArray (e.g.MAP).
e.g.
replacement.txt:
#txtTextVar - pDoc->m_TestVar1
I mean, that all places with #txtTextVar should be replaced with the content of pDoc->m_TestVar1.
How can I do this job?
|
|
|
|
|
Yes, a map is one solution. Implement it.
Kuphryn
|
|
|
|
|
Thanks you for your fast reaction,
but my problem is howto say my prog that "m_TestVar1" is m_TestVar1, you know what I mean? Let me make it clear,
when I have a string like "m_TestVar1" out of a textfile, how can I say my programm that it should replace #m_TestVar1 with the content of "m_TestVar1".
The problem is the assigment between "m_TestVar1" (as a given string) and m_TestVar1 as variable.
|
|
|
|
|
One solution is a map of, say, string key and "variable" value (whatever type you want).
Kuphryn
|
|
|
|
|
I think you misunderstand me.
Let me say it so:
i like to have a funktion with CString parameter.
<br />
int MyNewFunction (CString szVarName)<br />
{<br />
...<br />
return value;<br />
}<br />
szVarName should be the name of the variable. Now the function should return the value of the variable.
e.g.
<br />
m_iTest = 20;<br />
<br />
int iNewTest;<br />
iNewTest = MyNewFunction("m_iTest");<br />
<br />
<br />
Thanx for your help
|
|
|
|
|
Correct. In your example, one solution is a map of CString key and integer value.
Kuphryn
|
|
|
|
|
use some sort of struct that stores the name and the value and then store the struct in a map or array or linked list and then just go through the list with string comparisons and once you find the right one get the value
|
|
|
|
|
Can you give me a small sample please?!
|
|
|
|
|
this is just a sample as i said you can use any data storage thing you want like a linked list or map you could also use a class instead of a struct there this is just a small example of what i think your looking for
<code>
int m_Value1 = 0;
int m_Value2 = 1;
struct stuff
{
char*name;
int id;
};
stuff_array[2] =
{
{"m_Value1", m_Value1},
{"m_Value2", m_Value2},
};
int GetVal(CString name)
{
for(int i = 0; i < 2; i++)
{
if(name == stuff_array[i].name)
return stuff_array[i].id
}
}
</code>
|
|
|
|
|
I need a 16 bit compiler to compile the project that located at:
Microsoft Knowledge Base Article - 324409[^]
Because I tink BLDDRV.cpp (that Calls the 16-bit API which causes the INF driver index to be built ) need a 16 Bit compiler. Is it correct!?
I can NOT compile it by MSVC 6. I get many error by VC6 such as:
c:\98ddk\inc\win98\inc16\windows.h(181) : error C4226: nonstandard extension used : '_near' is an obsolete keyword
(Is older version of MSVC such as VC++ 1.52, 16 bit compiler?)
|
|
|
|
|
Behzad Ebrahimi wrote:
(Is older version of MSVC such as VC++ 1.52, 16 bit compiler?)
Yes. From time to time you can find a copy on EBay.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I found just book about VC++ 1.5, on ebay.com.
Can you help more me!
|
|
|
|
|
Behzad, send me your mailing address. I'll be happy to give you my copy of MSVC 1.52. I no longer use it and don't have it installed on my PC. Btw, it's also available on the MSDN discs (you need to be a subscriber).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
What the hell is it for?
I see them all the time in MFC code and have never had the need for it, so i've never bothered to read up on it...
Cheers
How do I print my voice mail?
|
|
|
|
|
A forward reference tells the compiler about a type (usually a class/struct) without giving the full definition. Its purpose is similar to a function prototype in that regard.
You most often use them when two classes have to refer to each other.
class Bar;
class Foo
{
Bar* m_pBar;
};
class Bar
{
Foo m_foo;
};
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
You cannot truly appreciate Dilbert unless you've read it in the original Klingon.
|
|
|
|
|
I kinda figured it was like a function prototype, but I wasn't sure...
Thanks for clearing that up for me
Cheers
How do I print my voice mail?
|
|
|
|
|
a class that has been declared but not been defined,the class is been called forward referenced.
|
|
|
|
|
I am trying to determin wether a point with certain koordinates is inside a circle determined by other 3 pointes.
I calculated the radius of the circel and the coordinates of its middle point
I now want to put the coordinates of the point I am examining into the circles equation to see wether its inside the circle or outside but becuse of inaccurate calculations (sqrt function etc.) I always get a very big error my calculations are correct as far as I can determine, how can I bypass this problem:
bool HszogTeszt (Pont a, Pont b, Pont c)
{
double hossz1qvd = Distanzqvd(a[0], a[1], b[0], b[1]);
double hossz2qvd = Distanzqvd(a[0], a[1] ,c[0], c[1]);
double hossz3qvd = Distanzqvd(c[0], c[1], b[0], b[1]);
double hossz1 = sqrt(hossz1qvd);
double hossz2 = sqrt(hossz2qvd);
double hossz3 = sqrt(hossz3qvd);
if (hossz1>= (hossz2+hossz3)) return false;
if (hossz2>= (hossz2qvd);
double hossz3 = sqrt(hossz3qvd);
if (hossz1>= (hossz2+hossz3)) return false;
if (hossz2>= (hossz1+hossz3)) return false;
if (hossz3>= (hossz2+hossz1)) return false;
double radiusqvd;
double s;
s = (hossz1 + hossz2 + hossz3)/2;
radiusqvd = (hossz1qvd*hossz2qvd*hossz3qvd)/(16*(s*(s-hossz1)*(s-hossz2)*(s-hossz3)));
double kx, ky;
ky = ((c[0]*c[0]-b[0]*b[0]+c[1]*c[1]-b[1]*b[1])*(c[0]-a[0])/2-(c[0]*c[0]-a[0]*a[0]+c[1]*c[1]-a[1]*a[1])*(c[0]-b[0])/2)/((c[1]-b[1])*(c[0]-a[0])-(c[1]-a[1])*(c[0]-b[0]));
kx = ((c[0]*c[0]-b[0]*b[0]+c[1]*c[1]-b[1]*b[1])/2-ky*(c[1]-b[1]))/(c[0]-b[0]);
int dpszamol;
{
double aux;
aux = ((FelszinPontok.PontHalmaz[dpszamol][0] - kx)*(FelszinPontok.PontHalmaz[dpszamol][0] - kx) +
(FelszinPontok.PontHalmaz[dpszamol][1] - ky)*(FelszinPontok.PontHalmaz[dpszamol][1] - ky) - radiusqvd);
if (aux<-1) return false;
}
return true;
}
Muad-Dib
mailto:adamo_piar@freemail.hu
Made in Hungary
|
|
|
|
|
I am using MFC in VC++ v7. I need to do two things:
1. Programmatically give my window focus, and put it over all other windows.
2. Take away my windows focus, but still leave it on top of all other windows. Or, if it is possible, exclude one, and just put my window on top of all others without giving it focus.
Any help would be great.
|
|
|
|
|
One solution is SetWindowPos().
Kuphryn
|
|
|
|
|
|
IHMO if a DLL or EXE is in memory it IS loaded
Secondly...how do you know it's in memory and how did you get it there?
Did you open the exe and copy the entire file into RAM???
Use LoadLibrary()
If after this you still feel the need to load a DLL manually you would probably have to read some of the advanced hooking articles on here...I recall and article that disscussed ways of changing your CPU's IP allowing you to hijack API calls and such, which is probably the direction you want to head in
Cheers
How do I print my voice mail?
|
|
|
|
|
HINSTANCE hinst_yourdll;
BOOL m_bCanDo;
hinst_yourdll = LoadLibrary( "yourneed.dll" );
m_bCanDo= FALSE;
if(hinst_yourdll)
{m_bCanDo = TRUE;
dllfunc_yourneed = ((LPFNDLLFUNC1) GetProcAddress( hinst_yourdll, "yourneedfunc" ));
}}
|
|
|
|
|
Hi !!
Please help me, i have the following problem with "read data from txt"
First of all I have #include <fstream> and there is also : using namespace std;
typedef int Pont[3]; // 3D (x,y,z) co-ordinates
<code>int Pointloader()
{ const int PontNum= 5;
int load[3]= {0};
Pont RendPoints[PontNum];
ifstream my_file("d:\\prog2004\\my_file.txt");
my_file >> (int)load[0] >> (int)load[1]>> ' ' >> (int)load[2] >> ' ' >> '\n';
my_file.close();
}</code>
DEBUG:
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'const char' (or there is no acceptable conversion)
Muad-Dib
mailto:adamo_piar@freemail.hu
Made in Hungary
|
|
|
|
|
Remove ' ' from this line:
my_file >> (int)load[0] >> (int)load[1]>> ' ' >> (int)load[2] >> ' ' >> '\n';
and change it to:
my_file >> (int)load[0] >> (int)load[1]>> (int)load[2];
Kamyar Souri
Booria CAD/CAM Systems
www.booria.com
|
|
|
|