There is a built in function from the Microsoft.VisualBasic assembly.
I can use it in VB like this:
APR = (Rate(TotPmts, -Payment, PVal, FVal, PayType, Guess) * 12) * 100
My current project is in Java or Javascript and I need to use this function.
Answers on the web say just add the namespace and assembly and use the same in Java or Javascript
So how can I use use Financial.
Rate in Java (or perhaps even porting the source code to it)?
Thanks for any help.
In a C# project(or other .NET projects), just simply add Microsoft.VisualBasic.dll as a reference into your project, you can use Financial.Rate in your code, don't forget to add the namespace using Microsoft.VisualBasic; It's very easy because all .NET languages (C#/VB/etc) uses the CIL (Common Intermediate Language), so the .dll files compiled from different languages can be shared.
In a Java project, things are quite different. You need to use JNA(Java Native Access). See JNA.
Related
Recently i created in php simple script to import words from a text file and randomly pick one of them. To achieve it i created such class:
class RandomizeWords {
public static function display() {
$contents = file_get_contents("../dictionary.txt");
$lines = explode("\n", $contents);
$randomWords = ucfirst($lines[array_rand($lines)]);
return $randomWords;
}
}
Now, for fun, i wanted to make it work using javascript instead of php but i'm missing something or javascript can't work on files without using technologies like ajax, jquery or node.js which, imo, are overkill for such simple task. Am i wrong or am i forced to use node.js or something similar?
You need to understand that PHP is a server side scripting language that is made for managing, working with, serving, reading and writing files, while javascript is a client side scripting language, that is restricted from system access for security reasons. The way the two languages communicate between two different systems is through AJAX requests, or just plain GET,POST,PUT & DELETE requests. You can try and use a FileReader() javascript class, if the file is local to the script, but it does not look like the function has cross browser support. Here is a link. Otherwise you need to start learning Asynchronous programming and node.js.
I have a some amount of Java code in my Project (more specificaly GWT)
I have decided to start using react for future features
Now the problem is that i need to access some Java enum in React to perform calls to server from Javascript (or whatever operation)
My questions are
A) Is there a way to access Java public enum values in Js ? If so ...how ?
B) Is there some tool to generate Javascript .js file from these enum and accesss it that way (maybe maven should know this ?)
Any ideas appreciated
If you are using GWT 2.8.0 you can use the newly introduced annotations. There is a very good blog-post about it: here
I was using the esprima AST generator for javascript and using node.js. It works great!
Now I need to process the resultant json and would really like to use groovy - I have used groovy for this very successfully in the past. I could use two passes (first use node to create the json files and then use a groovy script to process them). However, given the large number of files I will be processing it is preferable to me to use groovy entirely.
Does anyone know if a AST generator for javascript is available in either Java or groovy? Google searches were fruitless for me - way too many hits!
[Afterthought: If node.js is callable from groovy, then I would need a really good set of directions on how that might be made to work!]
I have a simple function written in python which I want to port to javascript.
I have compiled python 2.7 into a .so library, so thats not the issue.
The problem I'm having is that after I compile my program with cython, the function names get all scrambled up, which means I don't know how to preserve the functions when i run emcc.
Does anybody have any experience compiling python programs to js with emscripten?
Any information would be appreciated.
Note: I want to preserve the exact functionality to that of python, I don't want something that translates a python program into javascript.
This other question, with an accepted answer, complains about the same issue: Cython mangling function names and making it difficult to access from C++: Embed python function in C++
The accepted answer states that Cython isn't meant for this sort of thing at all, suggesting you can't do what you want in this fashion:
You're not going to be able to get the interoperation you want that way. If you open and inspect hello.c you won't find "static int say_hello" anywhere in there. Cython is designed for letting Python use C libraries, not letting C libraries use python.
The not-accepted next answer suggest that specifying public will not mangle the function name, although he also mentions linking problems.
# (in the generated C file hello.c)
__PYX_EXTERN_C DL_IMPORT(...) say_hello(...);
Worth a shot, but please consider the other options in the comments if it fails.
all
I have a situation when I need to use one com library(lets call it COMLIB) in IE, in any way (no matter). I usually used to do it like this:
var obj = new ActiveXObject("SomeProg.Id");
The problem is COMLIB, I can not obtain it's ProgID. (I'm not very good in com components, because I'm a web developer primarly.. ) I tried to use OLE viewer that comes with VS 2010, but had no luck. Tried to add ProgID to the registry but it didn't work eather.
I came to conclusion that I can create .net assembly (NETASB), add reference to COMLIB, write wrapper for COMLIB, create com server from NETASB, and use it as ActiveX object.
Is it a good approach, or maybe there is some better?
Thank you for interest and help