06-09-2021 12:52 PM
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.
Solved! Go to Solution.
06-11-2021 12:29 AM
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
06-11-2021 03:22 AM
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.
06-11-2021 03:23 AM
Regarding the issue of passing arrays to/from JavaScript, you could serialize the data to JSON and then pass as a string.
06-11-2021 03:53 AM
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:
06-11-2021 08:18 AM
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
06-11-2021 08:20 AM
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.
06-11-2021 08:33 AM
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
06-11-2021 08:44 AM
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
06-15-2021 04:59 AM
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.
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