|
What trouble am I gonna get into trying to convert C# code to FORTRAN 95 Code? DOes anyone have a solution to any known issues? Is there a .NET solution?
Jack Connolly
|
|
|
|
|
Is there a .Net Fortran 95 compiler?
|
|
|
|
|
You'll probably have some problems trying to convert .NET Framework classes to FORTRAN.
I don't know of any examples of this being done. But like the other posted said, look for a FORTRAN.NET solution. Fujitsu and Lahey are trying to get a .NET version of FORTRAN together.
RageInTheMachine9532
|
|
|
|
|
I am trying to write a crude version of c#.The fn. looks like this:
static void sscanf(string input, string format, params object[] paramlist)
{
string pattern = @"\b\S+\b";
MatchCollection matches1 = Regex.Matches(input, pattern);
MatchCollection matches2 = Regex.Matches(format, @"\b\S+\b");
for(int i = 0; i < matches1.Count; i++)
{
if (matches2[i].Value == "s")
paramlist[i] = matches1[i].Value;
else if (matches2[i].Value == "d")
{
try
{
int ii = int.Parse(matches1[i].Value);
paramlist[i] = ii;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
}
else if (matches2[i].Value == "f" || matches2[i].Value == "lf")
{
try
{
double dd = double.Parse(matches1[i].Value);
paramlist[i] = dd;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
}
}
}
and can be called for example as:
sscanf(str, "%s %s %lf %lf %d", os1, os2, od1, od2, oi1);
The problem I am facing is that the variables are being passed by value not by reference. Can anyone please help me? the c# compiler does not allow me to use the keyword ref in conjunction with params.
The cause of the problem - It seems to me is that object is not a reference type. This is how I tested:
say we have a fn. fn1 like:
static void fn1(object obj)
{
int i = 10;
obj = i;
}
now in main:
int i = 0;
object obj = new object();
obj = i;
fn1();
i = (int) obj;
i remains as 0 instead of 10.
pl. mail me at fd97207 yahoo if you know the answer.
|
|
|
|
|
String formatting like this is already supported in the .NET Framework. See my article, Custom String Formatting in .NET[^], for reasons why it is much better (also see the message board at the bottom) and ways to use methods like String.Format , Console.WriteLine (any TextWriter.WriteLine , actually), and StringBuilder.AppendFormat , as well as IFormattable implementations' ToString(String, IFormatProvider) methods.
The problem here, though, is that you're passing value types which are pass by value unless you use the ref keyword when passing them and in your method declaration. Since you're passing them in an array, you can't do this, though. They really don't need to be passed by reference, though - you're not changing them. Value types are allocated on the stack instead of the heap because it's more efficient (among other reasons, which are discussed throughout the .NET Framework SDK documentation and online).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I use System.Diagnostics.Debug.Assert(); a lot, but resently I have noticed that the asserts are compiled into release builds, so my release builds actually asserts
It only does it sometimes, sometime I can change something in my program and rebuild and it works as expected, but when recompiling, it starts to throw asserts again (of course only if it comes to a codition where I assert in the code, but that should be removed in release builds)
Anyone seen that before?
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]My Photos[^]
|
|
|
|
|
Debug.Assert - like many of Debug 's methods - uses the ConditionalAttribute specifying "DEBUG". So, make sure your build configuration with which you're having problems does not define the DEBUG pre-proc def. By default, only the TRACE pre-proc def is defined in Release builds.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I figured you would've, but I hesitated to say anything bad about the compiler...Microsoft may be watching.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
is there a way i can write a program to use my scanner to scan a document and save it as a .jpg
chad
|
|
|
|
|
try this article (http://www.codeproject.com/dotnet/twaindotnet.asp?target=scanner). It is good enough to do what you want. There is another one in msdn but is more complicated.
If you need all of the functionality of a scanner you have to build something custom.
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
Can someone explain me, how to get an URL from IE an how to open an URL from an application in IE.
|
|
|
|
|
The latter is easy:
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = "http://www.codeproject.com";
Process.Start(psi); This will open the URL in the default browser (see below for how to use IE specifically). The former is not as easy, but also not difficult.
In your project, add a reference to %WINDIR%\System32\shdocvw.dll. This will create an interop assembly which defines the InternetExplorerClass class. This represents either a new or running instance of IE. You can use either Nagivate or Navigate2 to direct the user to a URL using IE. You can use the LocationURL to get the current URL for the top-level instance of IE.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anybody know how to add custom items&values into this dialog? I mean custom attribute classes defined like in AssemblyInfo.cs (e.g.: AssemblyVersion ) whose are visible in this dialog.
Thank u for help.
|
|
|
|
|
What dialog are you talking about?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I mean "version" tab on "properties" dialog (after right-click on .dll or .exe file and selecting "properties" from pop-up menu). There is frame labeled "other version information". I want to add item there. And i want to do it throught attributes in c# (or by other way). Do u know now? Thanks for ur response.
btw i don't have english version of windowsXP so i asked my friend how are these things called. I hope he told me the truth 
|
|
|
|
|
Besides the attributes you already mentioned, there is only the AssemblyFileVersionAttribute (so that you can make the file version different from the assembly version, which is often good when performing upgrades to an existing code base for minor bugs).
Also, these are used by the compiler / assembler to create a VersionInfo block in the .rsrc section of the PE/COFF executable. If you wanted to do this using attributes, you'd have to write your own compiler.
If you want to extract information from custom attributes in your assembly, you could create a property tab by implementing the necessary COM interfaces (like IShellPropSheetExt ), load the CLR and your AppDomain using the unmanaged hosting APIs for .NET, then extract information from your assembly-level custom attributes, but I doubt that's what you're after.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ohh... so you say :"If you wanted to do this using attributes, you'd have to write your own compiler. "
cool idea! maybe in future, who knows...(i am ) but create property tabs sounds quite better. I will try it.
Thank u.
DNH
|
|
|
|
|
I am planning the design of a small app (read: a few hundred lines, fast execution). The app will run behind the scenes with no user I/O. I am looking into configuration files and I was considering using a local .ini or .xml file. Question: Which should I use? (Subquestion: should I use one?). The settings would probably only include a few crucial settings and due to the nature or the beast, a few of those would need to be encrypted (password fields or so.) Looking at the problem now I'm thinking it may be far simpler to just hard-code the user names and passwords into the file, but I hate doing that. XML would be fast and easy but it's large and unnecessary while .ini files would be the proper size but I don't know about any facilities for encryption at the field level. Any suggestions? Thanks.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
|
|
|
|
|
Use a .config file - the standard configuration file for .NET applications. Besides including all sorts of runtime configuration, key/value app settings, and what not - it's also an extensible system. See the IConfigurationSectionHandler interface in the System.Configuration namespace in the .NET Framework SDK for more information.
This is best, IMO, because it keeps an application's configuration in a common place and works with the .NET configuration model, which also includes general settings using the machine.config file.
While the documentation I mentioned should mention this, a .config file is either Web.config for ASP.NET or MyApplicationName.exe.config (obviously, replace "MyApplicationName" with the actual exec name) and is in the same directory as the application. This is all default, anyway.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Duh, I should have thought about that. For some reason the standard .config completely slipped my mind. Thanks very much Heath.
Brian
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
|
|
|
|
|
I have a form, and on this form is a Panel control. When the form is inherited, I want the developer to be able to click on the form itself, or on the panel, and have a set of DesignerVerbs appear. What Designers and Base Designers should I use with the Designer attribute?
Thanks in advance for any ideas.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
The form should use a derivative ParentControlDesigner . As far as the internal panel goes, you'll need to make it public so that the developer can actually select it, IIRC, otherwise the designer treats it as just part of the form that can't be selected individually. For that, you could either extend the Panel and attribute your derivative class with a ControlDesigner or ParentControlDesigner , or use the methods of the ParentControlDesigner attributed on the Form to add menu items to the ContextMenu .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath! That did the trick. I played with all sorts of designer and root designer patterns, but never thought to change the access level of the Panel. I changed it to 'protected', actually, and that worked great.
So second question. This one's not a huge deal, just an eye sore in my opinion. Can you make the Panel control NOT show up in the property browser? I.E. Even though the Panel is there, the property browser should still show 'Form1', or whatever.
Thanks again! This has been kicking me for some time. D'oh!
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|