|
It's hard to work out what your problem is. You want to lose the slash ? Where is it ? Why do you need to lose it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't want the special character.I need everything except special character.But incase of attribute where this = sign is there these special chracter is coming.
|
|
|
|
|
Hi everybody.I have problems when calling dll.
Here is the Dll function definition(from the vander's document):
<br />
__int16 __stdcall MW_GetDBRecord(HANDLE icdev, __int16 fsid,<br />
__int16 rec_size, char *buf, int *rlen)<br />
Input parameters: <br />
icdev: device handle <br />
fsid: selected table NO. <br />
rec_size: a record size space.<br />
Output parameters :<br />
Buf: return entire record data (you need give buf enough space );<br />
Rlen: length of data .<br />
And here is my code:
<br />
[DllImport("mwhandset")]<br />
public static extern Int16 MW_GetDBRecord(IntPtr icdev,Int16 fsid,<br />
Int16 rec_size,ref string buff,ref int rlen);<br />
<br />
...<br />
<br />
private void button3_Click(object sender, System.EventArgs e)<br />
{<br />
...<br />
int rlen = 0;<br />
string buff;<br />
buff = " ";
MW_GetDBRecord(m_icdev,0,16,buff,ref rlen);<br />
}<br />
<br />
When calling MW_GetDBRecord it raise "System.NullReferenceException: Object not set to an instance".I'm sure the function has completed on the device,
because rlen=16(the record size) when the exception raised.So I think it is caused by type incompatibility,most likely the buff parameter.What type should I
use corresponding to "char *buf"? Or it is caused by any other reason?
Can anyone help me? Any idea will be appropriate.
|
|
|
|
|
This has to be
Xiaoming Qian wrote: [DllImport("mwhandset")]
public static extern Int16 MW_GetDBRecord(IntPtr icdev,Int16 fsid,
Int16 rec_size,ref string buff,ref int rlen);
Like this:
public static extern int MW_GetDBRecord(IntPtr icdev, int fsid,<br />
int rec_size, [Out] byte[] buf, int bufSize);<br />
And this has to be
Xiaoming Qian wrote: MW_GetDBRecord(m_icdev,0,16,buff,ref rlen);
this
int size = 256;
byte[] buf = new byte[size];
MW_GetDBRecord(m_icdev, 0, 16, buf, size);
I suggest you read these articles.[^]
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
Thank you, it works.
|
|
|
|
|
Hello everyone,
I use the following code to place an image "temp.jpeg" into an array and then write the array into a remote database.
int FileSize;<br />
byte[] ImageArray;<br />
FileStream fs;<br />
int iBytesRead;<br />
<br />
OpenFileName = "temp.jpeg";<br />
<br />
fs = new FileStream(OpenFileName, FileMode.Open, FileAccess.Read, FileShare.Read);<br />
FileSize = Convert.ToInt32(fs.Length);<br />
<br />
ImageArray = new byte[FileSize];<br />
iBytesRead = fs.Read(ImageArray, 0, FileSize);<br />
fs.Close();
I was wonder what I should do if the image is not a file such as "temp.jpeg" and it is the image displayed in a Button?
Can someone be kind enough to help me out on this one?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
You can save the image displayed in a Button to temporary file, and after that read from this file. Or you can save this image to stream, and then read it's data to array.
My english is not so good. Please, correct my errors.
Best regards, Alexey.
|
|
|
|
|
Does anyone know if it is at all possible to take an ImageList of large icons, resize them, and dump the smaller images into another ImageList? I am trying to do this dynamically since I will not have any smaller versions of the icons available to me.
|
|
|
|
|
I am pretty sure I have some sort of syntax problem here but I can't get my head around it, dont see anything wrong.
I have made a class called cRoom, I create several room objects from this and shove them in an ArrayList.
class cRoom
{
//variables left out for better viewing
public cRoom(//insert loads of strings and ints here)
{
}
// All the public get/sets go here, again left out for better viewing.
}
//at some point in my Main() program ill call a method called North
//rActive is a cRoom object, arrRoomList is an array of cRooms
rActive = North(rActive,arrRoomList)
// The method for North
public static cRoom North(cRoom activeRoom, ArrayList roomList)
{
if (activeRoom.NORTH != 0)
{
foreach (cRoom room in roomList)
{
if (room.RID == activeRoom.NORTH)
{
return room;
}
}
}
else
{
Console.WriteLine("I can't go that way.");
return activeRoom;
}
}
Anyway when the code is compiled I get two errors.
Inconsistent accesibility: return type ....cRoom is less accessible than method.....North
Inconsistent accesibility: parameter type...cRoom is less accessible than method....North
Thanks in advance. =)
|
|
|
|
|
The cRoom class is private and the North method is public. That means that the method is available outside of the surrounding class, but it's unusable as it's impossible to create the cRoom object that is needed for calling it.
Just make the method private also.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks! Worked a charm.
Its decided to throw another one at me now.
'Adventure.Program.North(Adventure.Program.cRoom, System.Collections.ArrayList)': not all code paths return a value
which I am guessing has something to do with the ArrayList
im only returning the cRoom object
|
|
|
|
|
Not all code paths return a value...
What code paths is it refering to?
code paths in a class or in the method?
|
|
|
|
|
the variables in my class cRoom are private
but they all have public get/set returns
I dont see what I am missing
|
|
|
|
|
eh woops I think I just figured it out
edit:
eh nope, still the same thing
each room has a number associated to their north south east and west exits
if its 0 there is no exit that direction
otherwise its 101 or 102 etc.
so if activeRoom.NORTH != 0 then its going to == 102 or another number
then I take that number and shove it into int RID
then I search each cRoom in the arraylist for that value
and if it finds it then it takes the rooms value and drops it into the activeRoom and its returned
|
|
|
|
|
Ok I solved the problem...
For some reason it didnt like the fact that I had the return activeRoom; in the follow position
foreach (cRoom room in roomList)
{
if (room.RID == RID)
{
activeRoom = room;
return activeRoom;
}
}
So I moved it here
foreach (cRoom room in roomList)
{
if (room.RID == RID)
{
activeRoom = room;
}
}
return activeRoom;
and it worked fine
I guess I cant have a return value in a foreach loop
Thanks for your help. =)
|
|
|
|
|
jblouir wrote: I guess I cant have a return value in a foreach loop
You can, although it's good form to only have one return, at the end of a method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
jblouir wrote: im only returning the cRoom object
Not always, that's what the error message is saying.
Look at the logic in the method. If activeRoom.NORTH is non-zero but not found in the list, the method doesn't return anything.
---
single minded; short sighted; long gone;
|
|
|
|
|
If you declare a method that returns a value, you must make sure that all places where you may exit the function will return a value of that type. Example:
public int MyFunc()
{
if (errorcondition)
{
return 2;
}
else
{
...
}
return 0;
}
}
|
|
|
|
|
I am trying to use the same class to populate the second list in my second class, but the list will have the last set of values. The only way that it work if I instantiate multiple classes, please help, why I can not use only instantiating my classes once . Here are the codes
<b><pre>First file</pre></b>
<code>
using System;
using System.Collections.Generic;
using System.Text;
namespace xpop
{
class Program
{
static void Main(string[] args)
{
_xobj xobj = new _xobj();
popxmlobj(xobj);
}
// Does work but have to instatiate the calss object twice need to re- use the calss object
static void popxmlobj1(_xobj xobj)
{
_AllValue aValue1 = new _AllValue();
aValue1.valueName = "VAL1Name";
aValue1.Values.Add("Val1");
xobj.fieldName = "FieldName1";
xobj.fieldValues.Add(aValue1);
_AllValue aValue2 = new _AllValue();
aValue2.valueName = "VAL2Name";
aValue2.Values.Add("Val2");
xobj.fieldValues.Add(aValue2);
}
// Works if I use this method
static void popxmlobj(_xobj xobj)
{
for (int i = 0; i < 2; i++)
{
if (i == 0)
{
_AllValue aValue1 = new _AllValue();
aValue1.valueName = "VAL1Name";
aValue1.Values.Add("Val1");
xobj.fieldName = "FieldName1";
xobj.fieldValues.Add(aValue1);
}
if (i == 1)
{
_AllValue aValue1 = new _AllValue();
aValue1.valueName = "VAL2Name";
aValue1.Values.Add("Val2");
xobj.fieldValues.Add(aValue1);
}
}
}
}
}
</code>
<b>pre>Second file</pre></b>
<code>
using System;
using System.Collections.Generic;
using System.Text;
namespace xpop
{
public class _xobj
{
public string fieldName;
public List<_AllValue> fieldValues = new List<_AllValue>();
}
public class _AllValue
{
public string valueName;
public List<string> Values = new List<string>();
}
}
</code>
mohsenb55
-- modified at 10:07 Friday 15th June, 2007
|
|
|
|
|
mohsenb55 wrote: static void popxmlobj1(_xobj xobj)
{
_AllValue aValue1 = new _AllValue();
aValue1.valueName = "VAL1Name";
aValue1.Values.Add("Val1");
xobj.fieldName = "FieldName1";
_AllValue aValue2 = new _AllValue();
xobj.fieldValues.Add(aValue2);
aValue2.valueName = "VAL2Name";
aValue2.Values.Add("Val2");
xobj.fieldValues.Add(aValue2);
}
This code adds aValue2 to xobj twice, I assume this is not right ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Christian,
aValue2 is actually aValue1 I mistyped it. The problem is that I like to instantiate the _AllValue class only one time and re-use the same object multiple times. In the above code to get it to work, the _AllValue class is instantiated twice aValue1 and aValue2. I want to be able to re-use the same object, let's say _AllValue aValue = new _AllValue(); and re-use as many times I want too and not have to intantiate _AllValue twice.
Thanks for the response
|
|
|
|
|
I have a text file of the following format
"apple","orange","pear" etc
I have tried both char and string seperators but can't think of a way grab the data cleanly without including a " or , . I either end up with "apple" "orange" "pear" or "apple orange pear"
The code I have been using.
private static char[] charSeperator = new char[] { ',' };
private static string[] strSeperator = new string[] {"\",\""};
strArray = strLine.Split(charSeperator);
strArray = strLine.Split(strSeperator,StringSplitOptions.None);
Is there a simple way of grabing apple orange and pear from the text file, without having to do further data cleaning?
Thanks in advance for any help you can offer
Haz
|
|
|
|
|
You may want to try regular expressions...
"too much daily WTF for someone..." - Anton Afanasyev
|
|
|
|
|
Sorry Paul what do you mean by regular expressions? I'm only fairly new to this c#
Haz
|
|
|
|
|