|
I was actually thinking on "TRAIN Buffer" ,but in my language "tampon" actually is the word for "TRAIN Buffer"or 1.damper,2. bumper,3. fender, 4. shock, 5. buffer. I was not thinking at all at other meanings other than what i described ... sorry if i mislead you. I will change his name soon.
|
|
|
|
|
That's OK - it just made me laugh.
/ravi
|
|
|
|
|
Congratulations on getting your code to work This approach isnt very dynamic tho and if you add or remove fields you would have to modify your save/load methods. I suggest that you read some articles about Serialization. Start with XML serialization, that way you can open the xml file in your browser and see everything. binary serialization isnt very fun to look at :].
A FOO walked into a BAR, and the horse said..
|
|
|
|
|
I think I made it how I like it the most and i can proudly name it that is all right ... 2 nights over this but I bring it down right where I want it to be. Phew.
Now I am happy with it.
I know i must learn and assimilate /the faster the better/ the arrays and lists that you all master them soooo well, and i am angry for that, but... i will.
About this matter, some good exercises that cant be done without them(arrays&lists&othersLikeThem) ,and who can be done without make me thinking about what I know already but direct me to learn them well? Thanks,and I appreciate.
So, here is my Class:
using System.Windows.Forms;
using SaveLoadNamespace;
namespace ExtractionsNamespace
{
public class ExtractionsClass
{
SaveLoadClass slc = new SaveLoadClass();
public string tampon;
#region <_____ AddControl _____>
#endregion >AddControl-END<
public void AddControl(Control c, bool checkToAdd)
{
if (checkToAdd)
tampon += c.Name + " = true" + "\r\n";
else tampon += c.Name + " = false" + "\r\n";
}
public void AddControl(Control c, string textToAdd)
{
tampon += c.Name + " = " + textToAdd + " \r\n";
}
public void AddControl(Control c, int valueToAdd)
{
tampon += c.Name + " = " + valueToAdd + " \r\n";
}
public void EraseAll()
{
tampon = "";
}
public string buffer; string s = ""; int i, j = 0; bool tf;
private void Extracttor(string _TextToExtract_)
{
i = buffer.IndexOf(_TextToExtract_);
s = buffer.Remove(0, i);
if (s.Contains("\r\n"))
{
i = s.IndexOf("\r\n");
j = s.Length - i;
s = s.Remove(i, j);
}
if (s.Contains("="))
{
i = s.IndexOf("=") + 1;
s = s.Remove(0, i).Trim();
}
}
public int Extract_int(string _TextToSearchFor_)
{
if (buffer.Contains(_TextToSearchFor_))
{
Extracttor(_TextToSearchFor_);
i = int.Parse(s);
}
return i;
}
public bool Extract_bool(string _TextToSearchFor_)
{
if (buffer.Contains(_TextToSearchFor_))
{
Extracttor(_TextToSearchFor_);
}
if (s.Contains("true"))
{
tf = true;
}
if (s.Contains("false"))
{
tf = false;
}
return tf;
}
public string Extract_string(string _TextToSearchFor_)
{
if (buffer.Contains(_TextToSearchFor_))
{
Extracttor(_TextToSearchFor_);
return s;
}
return "string_?";
}
public void file_SaveFileX()
{
slc.file_SaveFile(tampon);
}
public string file_LoadFileX()
{
slc.file_LoadFile();
return buffer = slc.textToLoadInto;
}
}
}
And here is the implementation on form:
using System;
using System.Windows.Forms;
using WarningsNamespace;
using ExtractionsNamespace;
namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
WarningsClass wc = new WarningsClass();
ExtractionsClass ex = new ExtractionsClass();
private void buttonSave_Click(object sender, EventArgs e)
{
ex.EraseAll();
ex.AddControl(checkBox1, checkBox1.Checked);
ex.AddControl(checkBox2, checkBox2.Checked);
ex.AddControl(checkBox3, checkBox3.Checked);
ex.AddControl(numericUpDown1, numericUpDown1.Value.ToString());
ex.AddControl(numericUpDown2, numericUpDown2.Value.ToString());
ex.AddControl(comboBox1, comboBox1.Text);
ex.AddControl(progressBar1, progressBar1.Value);
ex.AddControl(radioButton1, radioButton1.Checked);
ex.AddControl(radioButton2, radioButton2.Checked);
ex.AddControl(radioButton3, radioButton3.Checked);
ex.file_SaveFileX(); label2.Text = wc.w2;
}
private void buttonLoad_Click(object sender, EventArgs e)
{
label1.Text = ex.file_LoadFileX(); label3.Text = wc.w5;
checkBox1.Checked = ex.Extract_bool("checkBox1");
checkBox2.Checked = ex.Extract_bool("checkBox2");
checkBox3.Checked = ex.Extract_bool("checkBox3");
numericUpDown1.Value = ex.Extract_int("numericUpDown1");
numericUpDown2.Value = ex.Extract_int("numericUpDown2");
comboBox1.Text = ex.Extract_string("comboBox1");
progressBar1.Value = ex.Extract_int("progressBar1");
radioButton1.Checked = ex.Extract_bool("radioButton1");
radioButton2.Checked = ex.Extract_bool("radioButton2");
radioButton3.Checked = ex.Extract_bool("radioButton3");
}
#region <_____ mouseProgressBar _____>
int somemousecoordonates;
private void progressBar1_MouseMove(object sender, MouseEventArgs e)
{
somemousecoordonates = e.X;
}
private void progressBar1_Click(object sender, EventArgs e)
{
progressBar1.Value = somemousecoordonates;
label2.Text = somemousecoordonates.ToString();
}
#endregion >mouseProgressBar-END<
BTW, this is what i call a perfect example of [Code Library]. Something like this somewhere, cant be found? Of course for other subjects and matters(not just for savings or loadings).
And the Output is looking like this somewhere in a text file:
checkBox1 = true
checkBox2 = false
checkBox3 = true
numericUpDown1 = 14
numericUpDown2 = 56
comboBox1 = red
progressBar1 = 5
radioButton1 = false
radioButton2 = true
radioButton3 = false
Thanks for all the support.
|
|
|
|
|
I need a suggestion from you:
I want to make a saving program that is for windows only (not for internet) and who can imitate the Forum(in general) type of writing a text , store and display. Like the one i am writing right now. With a list box to display some saved text from a file, a textbox under -to write and save into that file.And a comboBox that can sort all "posts". Basically this is the hard part, the rest are decorations.
How do you recommend me to do:
Make for every "post" a file (for 100 posts will be 100 files) and the sorting is based on those files-its more intuitive to program it this way for me in my stage.
OR - the very hard part: (because i know only the basics in string manipulation)...
Make a single file with all the text and sorted it out by manipulating a string who contain the entire file.(a string that can retain in itself 99999999999999 characters-its even possible?-i doubt it.
OR
Again a single file that can be sorted but with the help of another one that contain some [sortings by address] from that large one. Basically there will be 2 files one with keywords representing addresses and the text attached to them, and the second one with only the keywords address.
But This is a little overwhelming for me to think about and i seek help from you, the guru of programming world.
Please give me a good solution...and how to think it through(programmatically).
Thank you.
|
|
|
|
|
Hi,Frinds.
I have a code that install sql server 2005 through code with command line argument written in bat file.
It was working fine on my machine with out any problem.
But on other machine its not. its terminating with out giving any kind of error . the machine i am tring allready have .net framework, win installer 3.1 and crystal report framework. Can u please tell me the problem. Thank you
|
|
|
|
|
I'm using BO XI R2.
I want to modify the report.
Following is a code snippet which throws InvalidCastException;
and under that the Message is No Such Interfaces Supported.
Kindly suggest me a solution, if you have been able to crack it.
Also any ideas why such an exception.
using CrystalDecisions.CrystalReports.TemplateEngine;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.ObjectFactory;
using CrystalDecisions.ReportAppServer.DataDefModel;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.CommonObjectModel;
using CrystalDecisions.ReportAppServer.ReportDefModel;
ReportClientDocument reportClientDocument = new ReportClientDocument();
SessionMgr sessionMgr = new SessionMgr();
EnterpriseSession enterpriseSession;
EnterpriseService enterpriseService;
InfoStore infoStore;
InfoObjects infoObjects;
InfoObject infoObject;
ReportAppFactory reportAppFactory;
string sampleReportName;
enterpriseSession = sessionMgr.Logon("administrator","","localhost","secEnterprise");
enterpriseService = enterpriseSession.GetService("InfoStore");
infoStore = new InfoStore(enterpriseService);
sampleReportName = "World Sales Report";
infoObjects = infoStore.Query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME='" + sampleReportName + "' And SI_INSTANCE=0");
infoObject = infoObjects[1];
reportAppFactory = (ReportAppFactory)enterpriseSession.GetService("","RASReportFactory").Interface;
reportClientDocument = reportAppFactory.OpenDocument(infoObject.ID,0);
reportClientDocument = reportAppFactory.OpenDocument(infoObject.ID,0); code segment throws the Exception
modified on Tuesday, September 7, 2010 2:30 AM
|
|
|
|
|
Please clarify exactly which statement throws the exception and the full text of all messages produced by the exception. My guess is that the interface you are calling does not return the object type that you think it does.
It's time for a new signature.
|
|
|
|
|
reportClientDocument = reportAppFactory.OpenDocument(infoObject.ID,0);
throws System.InvalidCastException
Message is No such interfaces Supported
following is the stack trace
at CrystalDecisions.ReportAppServer.ClientDoc.ISReportAppFactory.OpenDocument(Object DocID, Int32 Options)
at BNPP.Reports.Common.GenerateBOReport.GenerateReport(String _reportName, String _fileName, String _repositoryName, String _fileExtention, Boolean& bolChechEmpty, Decimal minFileSize) in \GenerateBOReport.cs:line 146
|
|
|
|
|
From the information you provide I cannot see why it would throw this error. I suggest you try the documentation or contacting the provider of the library code for assistance.
It's time for a new signature.
|
|
|
|
|
infoObject = infoObjects[1];
Array indices in C# are 0-based. Shouldn't it be
infoObject = infoObjects[0];
instead ?
|
|
|
|
|
in here we are dealing with SAP Business Objects(BO).
Here the indices start from 1.
so an index of 0 gives index out of range exception.
|
|
|
|
|
Any reason you're asking this question in a C# forum then?
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
I didn't get the appropriate forum in which i could ask this question.
|
|
|
|
|
You should probably try somewhere like BOB[^] or an appropriate Tek-Tips[^] board.
Please respect the Forum subject, thanks.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
I never used SAP Business Objects, so I won't be able to help any longer.
What I would do, if I were you, is to find whereas :
- the problem is on the reportAppFactory variable (which wouldn't be of type needed)
- or the problem is on the first parameter of the OpenDocument method (maybe try with infoObject instead of infoObject.ID, as it seems this method expects an object as its first parameter)
But these are only educated guesses and could be completely wrong as I'm not a SAP BO specialist.
Good luck.
modified on Tuesday, September 7, 2010 10:16 AM
|
|
|
|
|
The documentation of that OpenDocument function seems to be very low quality. According to the stack trace ("OpenDocument(Object DocID, Int32 Options) "), the first parameter is an Object , but obviously the function requires an object implementing a specific interface...
|
|
|
|
|
Hi
I am writing a C# app that talks TCP/IP to a development board. The board has C command struct packets defined below.
#define MAX_PACKET_PAYLOAD 1024
typedef enum packetCmds_enum {
PC_TO_DSP_WRITE = 1,
PC_TO_DSP_READ = 2,
DSP_TO_PC_ACK = 3
}packetCmds_enum;
//@brief This packet is sent from the DSP to the PC as a command.
typedef struct cmdPacket_type {
packetCmds_enum cmd; //&lt; Should be 32 bits
Uint32 size; //&lt; Set to zero if no data
Uint32 addr; //&lt; Target address
Uint8 data[MAX_PACKET_PAYLOAD];
Uint32 checksum; //&lt; Includes cmd, size, addr and data.
} cmdPacket_type;
I started programming it as public struct but then ran into an issue with the Uint8 data array. If I use
byte[] data = new byte[MAX_PACKET_PAYLOAD]
then I won't get the same structure because its an object.
I'm also using the System.NET.socket library to get the packet from the board.
socket.Receive(bytesReceived)
I've learned that I can't typecast bytesReceived to cmdPacket_type, so whats the cleanest way for me to parse the packet?
I also have to send packets to the dev board, but once I understand the conversion between un-managed and managed code (if thats even possible), I should be able to figure it out.
Thanks
Cheers
|
|
|
|
|
Hi,
here is a partial answer for you:
1.
in order to call native (or unmanaged) code from C#, you need P/Invoke. It isn't very simple, however there is a lot of information available, use Google. I have an unfinished article here[^]. Unfortunately for you, structs will be handled in part 2, which isn't available yet.
2.
to mimic native numeric arrays (with a constant size) in a C# struct, you need MarshalAttribute; it may look like:
struct ... {
...
[MarshalAs(UnmanagedType.ByValArray, SizeConst=1024)]
byte[] byteArray;
...
}
|
|
|
|
|
From the information you've supplied, this looks like it should work:
using System.Runtime.InteropServices;
public enum PacketCmds
{
PC_TO_DSP_WRITE = 1,
PC_TO_DSP_READ = 2,
DSP_TO_PC_ACK = 3
}
[StructLayout(LayoutKind.Sequential)]
public struct CmdPacketType
{
public const int MAX_PACKET_PAYLOAD = 1024;
public PacketCmds cmd;
public uint size;
public uint addr;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType=UnmanagedType.U1, SizeConst=MAX_PACKET_PAYLOAD)]
public byte[] data;
public uint checksum;
}
|
|
|
|
|
Instead of PInvoke, I recommend to use a C++/CLI wrapper. Easy to implement and it has less "magic" involved.
|
|
|
|
|
hi guys
i can send file with bluetooth from pc to any phone with inthehand library that phone must be accept recive file
and now how to send file without accepting from phone ?
thanks a lot
|
|
|
|
|
Why do you want to do that? I wouldn't like my phone receiving a file without me knowing about and accepting it. Sounds fishy.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
thanks for reply
i want to send file from pc to phone with bluetooth without accepting from phone and when send directly send to phone
thanks a lot
|
|
|
|
|
I don't think you can, and even if it is possible, you shouldn't.
|
|
|
|
|