|
Thanks, that's what I thought.
I've throttled the processing at either end but never tried to control the actual traffic.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
I have a file which has EBCDIC data. I need to convert this into ASCII. But since this EBCDIC data also has 'packed decimal' i'm not able to convert this.
Kindly let me know how to unpack this packed decimal, then later i can convert them to human readable ASCII format.
Thanks!
Deepa
|
|
|
|
|
Hi, Have you found a solution for this. I am running in to the same issue
|
|
|
|
|
See my answer off initial post.
|
|
|
|
|
1. Make sure you are getting the file transferred as binary (BIN) not text from the AS/400 (MF). Default would be text which will alter your values before you can read them.
2. Here ya go (C#):
```
using System.Linq;
namespace SomeNamespace
{
public static class SomeExtensionClass
{
public static decimal FromPackedDecimal(this byte[] value, byte precision = 2)
{
if (value.Length < 1)
{
throw new System.InvalidOperationException("Cannot unpack empty bytes.");
}
double power = System.Math.Pow(10, precision);
if (power > long.MaxValue)
{
throw new System.InvalidOperationException(
$"Precision too large for valid calculation: {precision}");
}
string hex = System.BitConverter.ToString(value).Replace("-", "");
var bytes = Enumerable.Range(0, hex.Length)
.Select(x => System.Convert.ToByte($"0{hex.Substring(x, 1)}", 16))
.ToList();
long place = 1;
decimal ret = 0;
for (int i = bytes.Count - 2; i > -1; i--)
{
ret += (bytes[i] * place);
place *= 10;
}
ret /= (long)power;
return (bytes.Last() & (1 << 7)) != 0 ? ret * -1 : ret;
}
public static decimal FromPackedDecimal(this string value, byte precision = 2)
{
return System.Text.Encoding.GetEncoding("IBM037")
.GetBytes(value).FromPackedDecimal(precision);
}
}
}
```
Details on specification: Packed Decimal Format
Cheers!
Willow
modified 10-Jun-20 13:20pm.
|
|
|
|
|
I want to modify a table's structure with a method.
Please help how to write this method!
I've tried:
public void tableExpand(string tableName, string colName)
{
...................
dataCommand.CommandText =
"ALTER TABLE @tableName" +
"ADD @colName real";
SqlParameter tableParam = new SqlParameter();
tableParam .ParameterName = "@tableName";
tableParam .Value = tableName;
SqlParameter colParam = new SqlParameter();
colParam .ParameterName = "@colName";
colParam .Value = colName;
dataCommand.Parameters.Add(tableParam);
dataCommand.Parameters.Add(colParam);
.....................
}
But this isn't the right way
|
|
|
|
|
Is it possible to parametize a stored procedure? I need a table to store some vectors. I must calculate the dimension of the vector space, and then to build the table with this parameters.
Ex: V(0.2 4.5 2.1 0.0 5.1 1.0........). This is a document vector, and its dimension would be, the no. of distinct words in a document collection.
|
|
|
|
|
Hi,
I have a Project combobox which I populate from the values from database table.
I want ask user to add new project if he does find the revevant project in the list and so as update the database table.
Is it possible in windows c# ?
Thanka in advance
|
|
|
|
|
priyanka_jns wrote:
Is it possible in windows c# ?
yes
|
|
|
|
|
can u please tell me . How ?
|
|
|
|
|
Hi All,
I m accessing the notes mail using notesDocument, I am able to get all teh properties of mail but if I want to access the mail like it is manually done, (color changes). how would I access the mail in that way..
My main problem is , I have infected file attach to lotusnotes mail and it is not detecting while I am accessing mail properties programmatically but if manually clicking it does..
I am using Domino dll for this automation.
Thanks
|
|
|
|
|
how do you check if a particular activeX is installed on the PC? I do not wish to catch InteropServices.COMException or any other exception just to determine if the activeX is installed.
|
|
|
|
|
You could look if HKEY_CLASSES_ROOT has a key corresponding to the ActiveX name, or if HKEY_CLASSES_ROOT\CLSID has a key corresponding to the ActiveX guid.
EDIT: used CLID instead of CLSID, now corrected.
modified on Tuesday, May 19, 2009 8:52 AM
|
|
|
|
|
how to convert any parameter type into object?
thanks
|
|
|
|
|
In .NET everything is derived from an object - so you can just cast it.
object o = (object) param;
Or is that not what you wanted?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I don't even think you need to cast it
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You are right, you can use the implicit cast, but I don't think that is the question he meant to ask. Hopefully, by answering the question he did ask too explicitly, it will prompt him to ask the question in better english...
(Did that make sense?)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I think so
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
your not by any chance trying to work with automation of some type are you? I remember doing Word automation where they want object as params in functions and you have to set them as object instances outside of the function as they need referencing.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Variant, I know he wants a variant, I can't beleive linq has brought back the variant (var)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It hasn't. Although that's what I first thought when I came across var.
When you do var x = from... , x is strongly typed (you may not know what its type is, but, whatever it is, you can't assign something of a different type to it unlike variants.)
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
|
Hi,
anybody had idea how to work with multiple stored procedures of data set (xsd) file in crystal report.
Thanks,
kanwal
|
|
|
|
|
Hi everybody, I have a strange problem in a simple following C# code:
float x = 15.15F;
float y = 9F;
float ans = x-y;
the answer should be: 6.15F
the answer I get: 6.14999962
when I use debug mode, x = 15.15 like it should be, and y=9, only after the substraction it happens, and I don't want to use Math.Round and all the workarounds, it's simple substraction, it should give simple answer, if someone have any idea about a possible reason I would be thankful.
Thank you all.
|
|
|
|
|
floaters can be annoying like that... I mean floats!
check out the documentation on them in MSDN i'm sure you will get your answer. Comes to mind thou that I seem to remember reading the Decimal is much more reliable. Is that an option for you? Of course you will have to look at the information on that too to check I am not imaging reading that (it happens sometimes - you can ask the flying pig outside my window if you don't believe me )
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|