LabVIEW Web Development Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Web VI - write to a file and jsli

Solved!
Go to solution

Hello All, 

 

I'm working on LabVIEW NXG to develop a web application and I'm finding it quite difficult when compared to labview. I'm unable to use certain functions in the web vi. I require reading and writing to config files in this application which is not available in labview nxg. 

 

Also, there's no split string function using a delimiter and I made an attempt on writing a Javascript code. The 1d string array output is not supported in the Javascript Library Interface and I'm left with no clue about what to do next. 

Kindly help me with your ideas.

 

Thanks,

Sruthi Sudhagar.

0 Kudos
Message 1 of 11
(5,760 Views)

Hi Sruthi,

 

I am curious to know where would you like to drop this config file and what are its contents? This can help me understand the problem better and possibly suggest a different approach. 

 

Regards,

Kiran

0 Kudos
Message 2 of 11
(5,706 Views)
Solution
Accepted by topic author sruthisudhagar

Hi Sruthi,

 

There is a "Search/Split String" function available in webVIs. You can use it in a loop and split until you have all the matches. I'm attaching an example VI which does it.

Sujay Narayana
Principal Software Engineer
Message 3 of 11
(5,698 Views)

Regarding the issue of passing arrays to/from JavaScript, you could serialize the data to JSON and then pass as a string.

Sujay Narayana
Principal Software Engineer
0 Kudos
Message 4 of 11
(5,697 Views)

Hi Sruthi,

 

What you have to bear in mind is that the webVI is running in the browser which heavily restricts access to the disk.


Depending on the life of the config you may have a couple of options:

 

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
0 Kudos
Message 5 of 11
(5,695 Views)

Dear Nikn,

 

Thanks for replying.

 

I am looking to host my application on a local web server which can be used only in a particular network with specific access to specific people and allow the admin user to edit the access file through this application. For this purpose I require editing the config files which will be stored in the server. I am not so familiar with this type of application and any inputs regarding this would greatly help me.

 

Thanks and Regards,

Sruthi Sudhagar

0 Kudos
Message 6 of 11
(5,690 Views)

Dear Sujay,

 

Thanks for replying.

 

I'm wondering why I am not able to find this in my LabVIEW NXG software while designing a web vi. I'm unable to find a lot more functions in NXG like invoke nodes and certain tree properties which is restricting me from achieving what I require. Since I am not so familiar with javascript, I'm not able to use that as an alternative.

 

Thanks and regards,

Sruthi Sudhagar.

0 Kudos
Message 7 of 11
(5,687 Views)

Hi Sruthi,

 

The problem for what you have described is that the webVI runs in the users browser - not on the server. Therefore it can't access files on the server.

 

Instead you will need to be able to load and send the file to the server some how. Either through a LabVIEW web service or you may be able to configure your existing web server to serve the file for you.

 

Then in your webVI you would use a http request to access it.

 

Cheers,

James

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 8 of 11
(5,681 Views)

Dear James,

 

Thanks for replying.

 

It would be of great help if you explain a little more for me to understand.

 

Thanks and Regards,

Sruthi Sudhagar

0 Kudos
Message 9 of 11
(5,678 Views)
Solution
Accepted by topic author sruthisudhagar

Hi Sruthi,

 

The important thing to understand is your webVI is not running on the server. It is downloaded to your computer when you go to the page on the server and runs on your computer. See the diagram below.

James_McN_0-1623750540125.png

This means that the webVI can't access the files on the server because it isn't running on the server.

 

Instead you need another bit of software - or you need to extend the web server software to provide the information about the files to the webVI.

 

Since web servers and clients talk HTTP anyway this is the most common method by far.


Exactly how to do that is a large topic itself! And probably depends on what web server you are running. If it is just reading the file - you may be able to add it to the web server's configuration to serve that file and don't need to do any coding.

 

You could use a LabVIEW Web Service as the web server which serves your webVI and also has LabVIEW endpoints where you can write code that executes on the server when the webVI sends requests to specific endpoints. LabVIEW Web Services are different from WebVIs as they are code to run on the server - not on the client.

 

This architecture is known as a single page application in the web world. I've been trying to find a simple explanation that doesn't assume you know the way it used to be done but I've struggled! This is a reasonable attempt though: What is a Single Page Application | Bloomreach

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 10 of 11
(5,655 Views)