|
The simplest way to use a barcode scanner is as a keyboard replacement - that when a barcode is scanned, the scanner hardware or software simulate pressing the keys that correspond to the barcode data. Some just act as if they are a keyboard, some need some software (normally called a 'keyboard wedge' or 'scan wedge' or something like that) to do this. Consult the scanner's manual.
For advanced uses, there may be an API available to get input directly from the scanner, bypassing the keyboard. You might want to do this if you want to differentiate between keyed and scanned data.
To configure what sorts of barcodes the scanner will read, the scanner normally understands special programming barcodes. You can scan these to set the scanner up. You'll find these codes in the scanner's manual. Again, for advanced uses, there may well be an API for programming the scanner.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm using a very fast loop and I'm using the Random object to get random numbers. The problem is that i'm suspecting that, as the loop is fast, numbers are not that random.
Is there a way to get to this? I've read something like locking the seed or something like that O_o
Thanx for any help.
|
|
|
|
|
|
It is outside.
Is there any way to randomize it more?
|
|
|
|
|
sergestusxx wrote: Is there any way to randomize it more?
What do you mean by randomizing it more? I've tested the random class and it seems to be quite random. You can specify a seed value in the class constructor.
Back in the old days with QuickBasic, one could use the statement RANDOMIZE TIMER and this would set the seed to whatever the PC's internal timer clock was at.
Try something like this:
Random randNum = new Random(DateTime.Now.Millisecond);
Everytime you have a new instance of randNum, it should generate a different set of random numbers (unless the code happens to be initiating at the same exact millisecond 1/1000 chance ).
Hope this helps some,
PJC
|
|
|
|
|
Problem is, it's not hard at all to have a loop hit that statement more than once per millisecond. And I've also seen some results that make me want a more random solution myself.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
BoneSoft wrote: it's not hard at all to have a loop hit that statement more than once per millisecond
It should be outside the loop. The original poster said outside the loop.
Another solution I thought of for the original poster was to create your own random number generator. The old Ada compiler that I have, the company had a sample random number generator program that was rather sophisticated.
|
|
|
|
|
|
The Random object produces a random number using the previous number as seed. It doesn't matter if you get the numbers an hour apart or a nanosecond apart, you will still get the same sequence of numbers.
Assuming of course that you use the same Random object, and doesn't create a new one for each random number.
---
b { font-weight: normal; }
|
|
|
|
|
If you doubt the "randomness" of System.Random (which is independent of the frequency you call Next() with), you should take a look at System.Security.Cryptography.RandomNumberGenerator and derived classes.
They tend to generate a better distribution of random numbers, from what I've read.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
|
|
Hi guys!
A quick question from a c# newbie. Please take a look at the following two examples:
EXAMPLE 1:
using System;
using System.Collections;
class Tester
{
public static void Main()
{
Hashtable x = new Hashtable();
int[] y = { 1, 2, 3 };
x["1"] = y;
int[] z = { 4, 5, 6 };
x["2"] = z;
Console.WriteLine(((int[])x["1"])[1]);
Console.WriteLine(((int[])x["2"])[1]);
System.Threading.Thread.Sleep(25000);
}
}
EXAMPLE 2:
using System;
using System.Collections;
class Tester
{
public static void Main()
{
Hashtable x = new Hashtable();
int[] y = { 1, 2, 3 };
x["1"] = y;
y[0] = 4; y[1] = 5; y[2] = 6;
x["2"] = y;
Console.WriteLine(((int[])x["1"])[1]);
Console.WriteLine(((int[])x["2"])[1]);
System.Threading.Thread.Sleep(25000);
}
}
Example 1 produces the desired output 2 and 5 whereas Example 2 returns 5 and 5.
The only difference being that in Example 1 two variables were used (y and z) to write data to the hashtable whereas Example 2 uses only one variable (y). IMO both cases should produce the very same output, but they obviously don't. Could anyone explain to me why not? I don't understand the logic behind this. Do I always have to use different variables when writing to a hashtable? That would be very inconvinient, especially if the table were to consist of hundreds or even thousands of items!
Any help is greatly appreciated!
Thans for your efforts!!!
Mazze
|
|
|
|
|
What you are storing in the hash table is not the array itsef, but a reference to the array. In the second example you are storing two references to the same array. That means that any change you make to the array will be visible from both references.
You don't need to use different variables, you only have to create separate objects.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa,
Thanks for your quick reply!
I wasn't aware of the hashtable only storing a reference of the array rather than the array values. That explanation was of great help to me.
I'm afraid, but I'm still stuck on how to go about creating separate objects. The main purpose of this particular hashtable is to save array values (the actual values, not a reference!) as 'y' changes. Could you give me an example as to how to resolve this without creating a new array for each item?
Thank you!
Mazze
|
|
|
|
|
But you have to create a new array for each item. A hash table is not capable of storing array values directly, you have to put the values in an array and store the reference to the array in the hash table.
I believe that you are not aware of where exactly you are creating the array.
The code:
int[] y = { 1, 2, 3 };
is the short form of:
int[] y = new int[] { 1, 2, 3 };
which is the same as:
int[] y;<br />
y = new int[] { 1, 2, 3 };
So, in that statement you are declaring a variable that can hold a reference to an array, then you create the array and store the reference in the variable.
If you want to make a copy of an array, you can use the Clone method. As long as the data in the array is a value type, it will create a fully independent copy of the array.
The Clone method returns an object reference, so you have to cast it to the correct type:
int[] y = { 1, 2, 3 };<br />
int[] z = (int[])y.Clone();
---
b { font-weight: normal; }
|
|
|
|
|
Hello
Your mistake in Example2 was changing the values of the same array, which eventually will change in the HashTable too.
Proposed solution:
Dynamically allocate another Array using the same name:
eg.
Hashtable x = new Hashtable();
int[] y = { 1, 2, 3 };
x["1"] = y;
y = new int[] { 4, 5, 6 };
x["2"] = y;
MessageBox.Show(((int[])x["1"])[1].ToString());
MessageBox.Show(((int[])x["2"])[1].ToString());
PS.
Beware of the Garbage Collector
Regards
|
|
|
|
|
Guffa,
Nader,
Thanks for helping me resolve this issue. I now have a grasp of what's meant by creating two separate objects. Everythings works fine! Great!!!
As mentioned earlier, I'm a newbie so sorry for asking questions that are crystal clear to advanced programmers.
Once again, thank you guys!
Have a great day!
Mazze
|
|
|
|
|
how to Windows Service.plx help me by step by step solution;
|
|
|
|
|
|
|
foysal mamun wrote: how to Windows Service
|
|
|
|
|
Hi!
How could I capture video from webcam (Microsoft LifeCam VX-3000) using .NET 2.0 or WinFX (.NET 3.0) and save it to WMV or AVI? Actually, using WinFX (WPF, WCF, etc.) is preferable.
Thank you in advance!
--
Yours sincerely,
Dmitry Alekseenko
|
|
|
|
|
Why you were voted a five I have no idea, maybe someone appreciates a clear-cut question following the posting guidelines...
Anyway I don't think that you can do this directly with .NET 3 (but not being able to install it on Win2K I wouldn't know). The easiest solution would be to grab DShowNET (just do a CP search for it), it's a wrapper around the DirectShow API and provides four or five very good examples on capturing from a webcam. There is even one example which does exactly what you want.
|
|
|
|
|
A question like this can be quite open-ended and actually requires quite a lot of knowledge of the camera as well as the internal processes available.
I would suggest you take a peak at Coding4Fun which is out on the MS website. (I think it is www.coding4fun.microsoft.com) There is a project out there on building a baby monitor system.
The article not only shows what the developer did to get it to work, but also illustrates the steps you would do in answering this question.
|
|
|
|