Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bartjuw authored Mar 27, 2024
1 parent 22753e6 commit abf3442
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@

# Using libantimonyjs in your project.

## In a webpage
- For use in a webpage just copy the contents of the ../release/v##### into a suitable directory in your website.
- In the webpage where you want to load the libantimony library just insert the following lines into the page so that your code can find the library:

```
<script src="/your_location/libantimony.js" type="text/javascript"></script>
<script src="/your_location/antimony_wrap.js" type="text/javascript"></script>
```

- Next write the javascript code to load the library:
```
<script type="text/javascript">
// Load library (asynchronous call):
var antimonyLibrary; // Holds libantimony
try {
libantimony().then((libantimony) => {
antimonyLibrary = new AntimonyWrapper(libantimony); // instantiates The AntimonyWrapper class
});
}
catch(err) {
console.log("Load libantimony error: ", err);
}
</script>
```
- Now you can call the Antimony instance to translate Antimony string to SBML string or translate an SBML string to Antimony string:
```
var result = antimonyLibrary.convertAntimonyToSBML( antimonyString ) ;
if(result.isSuccess()) {
sbmlResult = result.getResult(); }
```
or:
```
result = antimonyLibrary.convertSBMLToAntimony( sbmlString );
if(result.isSuccess()) {
sbmlResult = result.getResult(); }
```
- Both of these methods returns a Result object which has three methods:
- `result.getResult()`: Returns the translated string or the error message if isSuccess() is false.
- `result.isSuccess()`:
- `result.getWarnings()` : returns any warnings generated from the translation (Note: isSuccess will often return true if there are warnings.)
- dsf
## In node.js

## The basic APIs:
-

0 comments on commit abf3442

Please sign in to comment.