|
Gareth H wrote:
for (int i = 0; i < 64; i++)
{
if (i == 7 || i == 15 || i == 23 || i == 31 || i == 39 || i == 47 || i == 55)
{
}
}
So, does anyone know how I'd do a calculation to have the same effect as the above?
int counter = 0;
for (int i = 0; i < 64; i++, counter++)
{
if (counter == 7)
{
counter = -1;
}
}
-OR- (additional maths needed but without an extra variable)
for (int i = 0; i < 64; i++)
{
if (i % 8 == 7)
{
}
}
Hope it helps .
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Just use the modulus operator (%), like so...
private bool IsDivisibleBy(int divisor, int value)
{
return (value % divisor == 0);
}
if (IsDivisibleBy(8, 32))
{
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I would like to share with the .NET community, the NetAsm opensource project available on codeplex.
NetAsm provides a hook to the .NET JIT compiler and enables to inject your own native code in replacement of the default CLR JIT compilation. With this library, it is possible, at runtime, to inject x86 assembler code in CLR methods with the speed of a pure CLR method call and without the cost of Interop/PInvoke calls. With this library, it is possible for example to inject highly optimized code (using SSE, MMX) inside a method, in replacement of the default generated native code by the JIT compiler.
The current features of NetAsm are:
- Runs on x86 32bit Microsoft .NET platform with 2.0+ CLR runtime (x64 may be supported in the future
- Provides three different native code injection techniques: Static, DLL, and Dynamic.
- Static code injection: The native code is stored in an attribute of the method.
- Dll code injection : this method is similar to the DllImport mechanism but CLR methods are directly bind to the DLL function, without going through the interop layers.
- Dynamic code injection: you can generate native code dynamically with a callback interface that is called by the JIT when compilation of a method is occurring. It means that you can compile a method “on the fly”. You have also access to the IL code of the method being compiled.
- Supports for debugging static and dynamic code injection.
- Supports for different calling conventions: StdCall, FastCall, ThisCall, Cdecl. Default calling convention is CLRCall
- NetAsm can be used inside any .NET language (you can run assembler code inside VB!)
- Very small library <100Ko.
For additional information and documentation, please visit the NetAsm codeplex site.
Alexandre
|
|
|
|
|
I'm not sure where you should post this - maybe an article giving a demonstration of your project in use so people can see its benifits in action? - but certainly not here in this forum!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
>>but certainly not here in this forum!
Why not?
it's not a commercial product, it is related to the topic of the forum and it could be useful for the readers in here.
I don't see why it shouldnt be here..
|
|
|
|
|
Hi,
I have to create a parser that can parse a HL7 Message and load the data result into aSQL Server.
Does any one have any idea about this ?
|
|
|
|
|
I know nothing about this personally but a quick search found this blog[^] - the author seems to be pretty knowledgeable and there's alot of info on his site.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
There are some packages on SourceForge (see[^]) that might help. Depending on your application you could also use Mirth[^] to independently parse and route messages directly into the SQL DB. Then your C# code wouldn't have to deal with HL7 at all.
|
|
|
|
|
Are you even familiar with the nature of HL7 messages? They're the most convoluted message protocols I've ever seen - the first block of characters are the delimiters you should expect, and after that - a series of nested delimited strings of data. The book that explains all the fields (that don't always have to be there) is a couple THOUSAND pages long. You'll be better off buying code that's already been written, and be prepared to spend some big bucks, because HL7 is NOT for the faint at heart.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The problem with HL7 isn't the protocol itself. The most prevalent version is v2.X which is ASCII delimited because it dates back to when most medical devices communicated via RS-232. The most recent version (v3.0) is XML-based, but its adoption rate has been very slow so you’re unlikely to find facilities that actually use it yet.
The most difficult aspect of HL7 is that everyone has their own interface implementation. No two systems are alike. ASCII delimiters are easy compared with having to constantly renegotiate the protocol with another party even though it’s for the same purpose as the last interface you did.
|
|
|
|
|
Hi,
Could anyone tell me whether there is a C# equivalent of the java CharArrayBuilder class?
Regards,
Dave
Regards,
Dave
|
|
|
|
|
i would imagine that StringBuilder would be close, but i'm not all that familiar with java.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I don't think there is one. However, a string is really a null terminated character array + it has a ToCharArray method. As the previous poster said there's also the string builder if you need it.
Another alternative is to use a List<char>
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi,
I'm trying to run a ccxml, and consequently, a voiceXML page externally from the server (like through my application) and the documentation of the server mention that it can be done using HTTP POST.
Following is a simple example of html that works and successfully starts a call on a remote destination
<html>
<body>
<form method="post" action="http://localhost:4045/basichttp" enctype="application/x-www-form-urlencoded">
ID="Form1">
name: <input type="text" name="name" size="40" value="OutBoundCallEvent" id="Text1" />
<br />
URI to be contacted by the outbound: <input type="text" name="ToBeContacted_URI" size="52" value="10.2.50.42" id="Text5" />
<br />
VoiceXML URI: <input type="text" name="VoiceXML_URI" size="73" value="file:///C:/voiceXML/three.vxml">
ID="Text6" />
<br />
CCXML URI: <input type="text" name="uri" size="75" value="file:///C:/CCXML/outboundcall.ccxml">
ID="Text7" />
<br />
<input type="submit" id="Submit1" name="Submit1">
</input></input></input></form>
</body>
</html>
But I want to achieve the same effect through my c# application and I am using HttpRequest and HttpResponse to mimic submitting the form above.
following is my attempt on this
string uri = @"http://localhost:4045/basichttp";
string data = @"name=OutBoundCallEvent&ToBeContacted_URI=10.2.50.42&VoiceXML_URI=file:///C:/voiceXML/three.vxml&uri=file:///C:/CCXML/outboundcall.ccxml";
byte [] bytes = System.Text.Encoding.ASCII.GetBytes(data);
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(uri);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write (bytes, 0, bytes.Length);
os.Close();
HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
if (resp== null)
{
MessageBox.Show("Problem in sending response!");
}
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
string result = sr.ReadToEnd().Trim();
MessageBox.Show("All done!");
Now when I try to get the response using HttpResponse I get an error " The remote server returned an error: (400) Bad Request."
Q1 Does writing the data into the stream means the server has send the data just like pressing the submit button? or does the using the gerResponse method this happens?
Q2 Is there something im missing in order to achieve a simple submit function? I have tried sending some data over to an asp page and use response like above and it all seems to work fine.
Any help will be greatly appreciated.
Kind Regards
Fahd
|
|
|
|
|
I found out the problem I am not sending the data string in the proper format it requires escape characters for slashes etc!!!
Btw just to share I was advised to use a tool called Fiddler to examine the data sent to the server which in turn lead me to find out my mistake. Seems to be a pretty neat tool.
Fahd
|
|
|
|
|
Hi,
I had written a webservice.Now I need help to accompolish the following goals..
1.How to host the webservice?..since this i have to use in windows application.
2.How to consume this webservcie through the C#.net windows application.
My task is to write the Webservice,using this I will pick some data and that data I have to pass to a windows application/windows service where I will update the database.
|
|
|
|
|
balu12345 wrote: had written a webservice.Now I need help to accompolish the following goals..
OR
balu12345 wrote: My task is to write the Webservice,using this I will pick some data and that data I have to pass to a windows application/windows service where I will update the database
So you haven't written it then.
balu12345 wrote: 1.How to host the webservice?..since this i have to use in windows application.
Webservices have to be hosted in a web server - there is a clue in the name
It looks to me like you want someone to do your homework.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
or to fulfill a contract for em that shouldnt have been takin in the first place. i'm all for learning new things but one should at least do a bit of reasearch about what a client wants before agreeing to provide it.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi
I don't know to do it..I need guidence but not the code.This is first time Iam working with webservice and windows applications.So I held all your help ...
|
|
|
|
|
Try BOL or Google, there are plenty of examples. Its far big a topic to cover in a forum.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
I have a form with a status bar that I want to be maximized whenever it is shown.
I don't want the form to have maximize or minimize buttons so I have set MaximizeBox and MinimizeBox to false. But whenever the form is shown it totally overlaps the taskbar effectively making it invisible.
I have played around with various combinations of FormBorderStyle and MaximizeBox/MinimiszBox/ControlBox settings to no avail.
The code below is enough to reproduce the problem I am having.
Any ideas how to achieve what I'm looking for.
Thanks,
dlarkin77
public class FormTest : Form {
private StatusStrip statusStrip1;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent() {
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.SuspendLayout();
this.statusStrip1.Location = new System.Drawing.Point(0, 395);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(643, 22);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(643, 417);
this.Controls.Add(this.statusStrip1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormTest";
this.Text = "FormTest";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public FormTest() {
InitializeComponent();
}
}
|
|
|
|
|
forget about the maximized start up state and set the size of the form manually (and the location).
this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
Not sure if you can do this in the designer - if not, put it in the constructor after the InitializeComponent call. You'll need to set the StartPosition to Manual.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
DaveyM69 wrote: forget about the maximized start up state and set the size of the form manually (and the location).
this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
I can't believe I didn't think of that!
Thanks very much.
|
|
|
|
|
1 ) I want a function to wait in thread of onbefore unload event for sometime. Can any one tell me how to do it in javascript.
2) Is it possible to make visibility of showmodaldialog window to false or move it away from the screen ?
Thanks in advance
|
|
|
|
|
You have been a member of CodeProject for a year and yet you post a javascript question in the C# forum, hmmm interesting.
led mike
|
|
|
|