F# interactive session persistance and other such user questions - f#

Is there any way of persisting my F# session or serializing it into a file? i.e. so I can hand it to a friend and say "run this" and they will be at the same place I was? I know forth had this ability but I can't find any way of doing this.
An alternative would be a log file or something of similar ilk, but ideally it would strip the output and just give me the code I wrote.
On the topic of user questions, is there a config file for F# so I can add some "always includes" or alter the defaults?

There is no way to serialize the F# Interactive session or create some log of commands automatically.
The typical user interaction is that you write all your code in F# Script File (.fsx extension) and evaluate code by selecting lines and sending them to F# Interactive using Alt+Enter. If you work like this, then the F# Script File is a bit like log of your work - and you can easily send it to other people.
The good thing about this approach is that you can edit the file - if you write something wrong, you can correct it and the wrong version will not appear in the log. The bad thing is that you need some additional effort to keep the source file correct.
Regarding automatic inclusions - you can specify options for fsi.exe in Visual Studio Options (F# Tools). The --load command line parameter can be used to load some F# source at startup.

Related

Outputting Dynamic Results in Abaqus

I ran a dynamic simulation in Abaqus 6.11, and need a way to output the results in an efficient manner. I would like to report the velocity (among other quantities) of all the nodes at all time steps. In the GUI I could create a field output and select each step one at a time to report, but this approach is not practical. Does anyone know how to do this? In the end I'm hoping to get one/multiple rpt files containing the data I need. Then I can write a script in Matlab for reading/performing operations with the data.
Thanks
You should write a script to automate the process for you. Since Abaqus exposes interface for writing Python scripts, you should try that out.
If you've never done something like that, then create a field report for one step/frame manually and then open abaqus.rpy file to see the code necessary to create that single output. Once you figure out how to do it for one step, write a script with a loop to do it for all steps.
When you open abaqus.rpy file, there will probably be a lot of code, depending on how much commands you had previously issued. The like you need to look for looks something like
session.writeFieldReport(some parameters...)
The script you write can be run via 'File > Run script'.
If you need actual help writing the script, maybe you should open a question with specific problem.

What's the best way to create a report on OpenERP

I try to create a report on OpenERP. There is several methods to do this task (openoffice plugin, XML files, RML files, etc.)
What's the quickest way to do that (and/or the most beautiful) ?
I've only used the RML files and I've been happy with the result. I haven't tried the OpenOffice method, but it seems like the conversion step from SXW to RML would be more hassle. When I edit an RML file, I just save it and click on the report button in the client to try it out. No compilation or conversion necessary. OpenOffice might be useful if I wanted to let business users make minor changes to reports, but I suspect that all the weird data extraction code would confuse them.
I haven't tried the XML report technique, so I can't comment on it.
I assume you've seen the documentation on writing reports. I just noticed a section that talks about changing the corporate default headers, and it only seems to be described for XML reports. I haven't looked any further, but that might be a reason to use XML instead of RML. I know we would like to get rid of the corporate headers for some internal documents.
Web kit Report is the easiest way to make a Report, to install webkit report
sudo apt-get install wkhtmltopdf
and install report_webkit module in OpenERP, it will show the tab in the company, within company you can make simple report using OpenERP GUI,
for Advance report You must learn the maco template,
Thanks..!!
If you know html then webkit report using mako. Webkit reports are very easy to create compare to rml.
For simple reports I prefer using rml reports, by creating an sxw file first and then convert it to rml using the script in the openerp module base_report_designer.
For complex report and also for making the report more beautiful, I prefer to use jasper_reports module. With the help of iReport we can generate beautiful reports. We can also use jdbc datasource which can be connect to our database and pull the data. Subreport is also possible using jasper_reports
There are also other reporting tools like aeroo reports,using xsl file, openoffice plugin etc.
jasper report can be used to create OpenERP report using sql query.
Here is a way I have shown in my post which describes creating a report based on SQL query in OpenERP 7. Please follow this link for the details. Hope this will help others.
http://sajjadhossain.com/2013/06/30/openerp-7-creating-report-using-sql-query/
the most easiest and simple and quickest way to edit,customize and create your own report is editing the .rml files knowledge from experience so far

Is there a tool that allows to edit related code in single file?

My idea is that it's much easier to edit related code when it sits in single "work" file. E.g. in Rails application when you implementing some functionality you may edit 1 function per file in the following files: integration test, controller test, controller, model, controller helper. So if it would be possible to 1) mark this code fragments 2) automatically collect them in "work" file 3) edit them togather 4) the tool synchronizes (puts back) the changes; it could simplify development process in many cases. Especially if you need to go through many tweek-and-try iterations.
Vim works fine for this. Install the Rails.vim(1) plugin and with the command :AV you can open a vertical split with the accompanied tests/specs, or :RV to open related files like migrations and views (depending on whether you're viewing model or controller). When you're workspace becomes to cluttered, use :only to go back to one file. Splits are the best way to manage multiple related files IMHO. You can even open the same file twice to see two parts of the same file. It's not exactly the same as you are describing, but it comes close.
1: http://rails.vim.tpope.net/
Just open up Vim and open some windows. What's the problem?

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use new ActiveXObject(). If you are using VBScript, you can just use CreateObject.
See this article for some background.

Delphi: Check whether file is in use

I want to write to/delete a file but sometimes I get a crash if the file is in use by another program. How do I check to see whether the file is opened by another process or I can open it for writing?
The problem is, that between the time you check to see if you could get exclusive access and opening the file, something else gets exclusive access to the file, and you get the exception anyway.
The only fool proof way to see if you can get an exclusive lock on a file is to try and get an exclusive lock on the file, if you get it you have it.
If not, you catch the exception, and either
Go do something else
Wait a while and try again
It's one of life’s situations where it's better to ask for forgiveness than permission :)
There is a new way to get the origin of file locking for Vista and up here:
http://www.remkoweijnen.nl/blog/2011/01/03/cannot-access-files-but-need-the-origin/
UserMode:
The best way to write to a locked file is to ask the user to close it in the other process. In batch processes you should ignore such a file and log the problem. Providing the name of the other process is a very good way to find a solution for the user.
Not sure in which programming language you'd like to check if you can write to a file. In Java, java.io.File.canWrite() can do the job for you.
General:
In UNIX-like OS, you can use the lsof command.
If you want to see which program holds a handle to your file, use the Process Monitor (download from MicroSoft).
This tool has a command line interface, so you could use your language's scripting interface (for example java.lang.Process) to run the tool and display a useful error message.
IsFileInUse as given in http://delphi.about.com/cs/adptips1999/a/bltip0999_3.htm

Resources