
Quote from smartmedia on May 8, 2023, 11:59 amHi..
I remember in Neobook we could load a set of variables from a text file. Can we do the same in NeoWeb ? I thinking to use that method so i can change language.
Thanks
Hi..
I remember in Neobook we could load a set of variables from a text file. Can we do the same in NeoWeb ? I thinking to use that method so i can change language.
Thanks
Quote from Gaev on May 8, 2023, 4:26 pm@smartmedia
I remember in Neobook we could load a set of variables from a text file.
Are you referring to the PopulateStr command ? ... or something else.
I thinking to use that method so i can change language.
Can you post an example of the content of the Text file(s) ... and what the end result would look like ?
I remember in Neobook we could load a set of variables from a text file.
Are you referring to the PopulateStr command ? ... or something else.
I thinking to use that method so i can change language.
Can you post an example of the content of the Text file(s) ... and what the end result would look like ?

Quote from smartmedia on May 9, 2023, 6:56 amHi @gaev,
It's been more then 10 years so all my source code is gone, my computer has hited by thunder so i lost everything. But i remember that was something like that:
Variable1= "Value"
Variable2 ="Value"
Variable3 ="Value"
You could load all the variables from the text file and save them to text file. I am not sure if it was plugin from Hans-Peter or any Developer or native NB.
The point is that it would be usefull if you can have such functionality to load and save all at once the variables.
Hi @gaev,
It's been more then 10 years so all my source code is gone, my computer has hited by thunder so i lost everything. But i remember that was something like that:
Variable1= "Value"
Variable2 ="Value"
Variable3 ="Value"
You could load all the variables from the text file and save them to text file. I am not sure if it was plugin from Hans-Peter or any Developer or native NB.
The point is that it would be usefull if you can have such functionality to load and save all at once the variables.

Quote from luishp on May 9, 2023, 9:48 am@smartmedia yes, in VisualNEO Win it's the SaveVariables command. Very useful.
In VisualNEO Web you can achieve something similar storing all you variables in JSON format. Then you can save and load all of them with a single command.Example:
CreateEmptyObject [mydata] SetVar [mydata.variable1] "value1" SetVar [mydata.variable2] "value2" SetVar [mydata.variable3] "value3" StringifyJSON [mydata] [finaldata] VarToLocalFile [finaldata] "finaldata.json"Regards.
@smartmedia yes, in VisualNEO Win it's the SaveVariables command. Very useful.
In VisualNEO Web you can achieve something similar storing all you variables in JSON format. Then you can save and load all of them with a single command.
Example:
CreateEmptyObject [mydata] SetVar [mydata.variable1] "value1" SetVar [mydata.variable2] "value2" SetVar [mydata.variable3] "value3" StringifyJSON [mydata] [finaldata] VarToLocalFile [finaldata] "finaldata.json"
Regards.

Quote from smartmedia on May 10, 2023, 9:16 amHi @luishp
what i am trying to do is to create a text file outside NeoWeb with the variables that contain the language, for example:
Variable1= "Value"
Variable2 ="Value"
Variable3 ="Value"
and then load the text file who contain the variables and replace the values.
I remember that this was happening in NB only with one command to load and one command to save the text file. I don't want to create 10k code for that, cause what you suggest is to write all variables prior to save them and i guess i must do the same to load them. The variables i want to load is more than 500.
So if there is any other way it could be useful.
Hi @luishp
what i am trying to do is to create a text file outside NeoWeb with the variables that contain the language, for example:
Variable1= "Value"
Variable2 ="Value"
Variable3 ="Value"
and then load the text file who contain the variables and replace the values.
I remember that this was happening in NB only with one command to load and one command to save the text file. I don't want to create 10k code for that, cause what you suggest is to write all variables prior to save them and i guess i must do the same to load them. The variables i want to load is more than 500.
So if there is any other way it could be useful.
Quote from iretz on May 10, 2023, 5:18 pmNB code (Coded by Mishem)
English.ini
MenuFile=File
MenuOpen=Open
MenuClose=Close
MenuEdit=Edit
etc.Spanish.ini
MenuFile=Archivo
MenuOpen=Abierto
MenuClose=Cerca
MenuEdit=Editar
etc.LoadVariables "[PubDir]\English.ini"
or
LoadVariables "[PubDir]\Spanish.ini"[MenuFile]
[MenuOpen]
[MenuClose]
[MenuEdit]
NB code (Coded by Mishem)
English.ini
MenuFile=File
MenuOpen=Open
MenuClose=Close
MenuEdit=Edit
etc.
Spanish.ini
MenuFile=Archivo
MenuOpen=Abierto
MenuClose=Cerca
MenuEdit=Editar
etc.
LoadVariables "[PubDir]\English.ini"
or
LoadVariables "[PubDir]\Spanish.ini"
[MenuFile]
[MenuOpen]
[MenuClose]
[MenuEdit]

Quote from smartmedia on May 11, 2023, 8:31 am@iretz
your example is correct but is not working on NeoWeb, i need the same procedure for NeoWeb. But thanks anyway..
your example is correct but is not working on NeoWeb, i need the same procedure for NeoWeb. But thanks anyway..

Quote from luishp on May 11, 2023, 9:55 amI remember that this was happening in NB only with one command to load and one command to save the text file. I don't want to create 10k code for that, cause what you suggest is to write all variables prior to save them and i guess i must do the same to load them. The variables i want to load is more than 500.
@smartmedia I don't understand you. I just suggest using variables within an object instead of isolated. This way you can manage all of them very easily: saving them into a local or remote file or even in a database with just two commands. Then you can load them very easily too.
I think that's the best approach for non trivial apps.
Note that you can easily transform an existing application just opening the source code with Tools > Source File Editor and using "Find and Replace" (but be sure to create a backup first, just in case)Regards.
I remember that this was happening in NB only with one command to load and one command to save the text file. I don't want to create 10k code for that, cause what you suggest is to write all variables prior to save them and i guess i must do the same to load them. The variables i want to load is more than 500.
@smartmedia I don't understand you. I just suggest using variables within an object instead of isolated. This way you can manage all of them very easily: saving them into a local or remote file or even in a database with just two commands. Then you can load them very easily too.
I think that's the best approach for non trivial apps.
Note that you can easily transform an existing application just opening the source code with Tools > Source File Editor and using "Find and Replace" (but be sure to create a backup first, just in case)
Regards.

Quote from smartmedia on May 11, 2023, 10:06 am@luishp
@iretz has described above exactly what i want, can we have load - save variables commands on VNW ?
@iretz has described above exactly what i want, can we have load - save variables commands on VNW ?

Quote from luishp on May 11, 2023, 10:09 am@smartmedia NOT in the exact same way (with isolated variables), but YES in a very similar way (using objects) :)
@smartmedia NOT in the exact same way (with isolated variables), but YES in a very similar way (using objects) :)

Quote from smartmedia on May 11, 2023, 10:27 am@luishp
Load and save variable commands in NB they only accept a file path and they load or save the contains of variables. On the other hand writing variables on code and then write a file is a compliantly other thing. So, can we have 2 commands ?
The first command will read the variables and their values from a local text file (could be local or remote) and replace their values of variables.
The second command will write all the active variables and their values in a local text file (could be local or remote).
And thats it..
Can we do that right now in NeoWeb as we do it in Neobook ?
Load and save variable commands in NB they only accept a file path and they load or save the contains of variables. On the other hand writing variables on code and then write a file is a compliantly other thing. So, can we have 2 commands ?
The first command will read the variables and their values from a local text file (could be local or remote) and replace their values of variables.
The second command will write all the active variables and their values in a local text file (could be local or remote).
And thats it..
Can we do that right now in NeoWeb as we do it in Neobook ?

Quote from luishp on May 11, 2023, 12:13 pm@smartmedia please check the attached sample app and decide yourself.
This is a sample to store and retrieve all the variables as a local JSON file. You can do it also in a remote file or database.
All the trick is using an object that stores variables instead of isolated variables.
Regards.
@smartmedia please check the attached sample app and decide yourself.
This is a sample to store and retrieve all the variables as a local JSON file. You can do it also in a remote file or database.
All the trick is using an object that stores variables instead of isolated variables.
Regards.

Quote from smartmedia on May 11, 2023, 4:21 pm@luishp
that solution is not working for me. I need the functionality of Load-Save Variable of NB. If we have something that do that work will be great..
that solution is not working for me. I need the functionality of Load-Save Variable of NB. If we have something that do that work will be great..

Quote from fkapnist on May 11, 2023, 7:45 pmQuote from smartmedia on May 11, 2023, 4:21 pm@luishp
that solution is not working for me. I need the functionality of Load-Save Variable of NB. If we have something that do that work will be great..
This JavaScript saves and opens variables as text form fields using cookies:
http://employees.oneonta.edu/higgindm/javascript/cookieEx.html
The function cookieForms saves and opens the text form content (or variables) of a page.
.
Notice: Cookies can be blocked or deleted, and cookie length should be less than or equal to 4096 characters.
Why not use VisualNEO
var-to-local-file.neoapp
to save a variablefiletovar.neoapp
to load a variable.
Quote from smartmedia on May 11, 2023, 4:21 pmthat solution is not working for me. I need the functionality of Load-Save Variable of NB. If we have something that do that work will be great..
This JavaScript saves and opens variables as text form fields using cookies:
http://employees.oneonta.edu/higgindm/javascript/cookieEx.html
The function cookieForms saves and opens the text form content (or variables) of a page.
.
Notice: Cookies can be blocked or deleted, and cookie length should be less than or equal to 4096 characters.
Why not use VisualNEO
var-to-local-file.neoapp
to save a variable
filetovar.neoapp
to load a variable
.

Quote from smartmedia on May 12, 2023, 8:50 am@fkapnist
Hi..
I don't want solutions that may, or not work according to conditions. FiletoVar command loads all content of a file into 1 variable.
What i want and is very clear is to load an external file i have made that contains all the variables that will change the language in the site. This function all ready exist in NB and is very good. I need the same in VNW.
Thanks for your time.
Hi..
I don't want solutions that may, or not work according to conditions. FiletoVar command loads all content of a file into 1 variable.
What i want and is very clear is to load an external file i have made that contains all the variables that will change the language in the site. This function all ready exist in NB and is very good. I need the same in VNW.
Thanks for your time.
Quote from Gaev on May 13, 2023, 12:31 am@smartmedia
As I read the various threads in this post, it appears that your requirement has changed somewhat; you are no longer asking for a command like SaveVariables in VNWin (you are text editing this file yourself).
So all you are asking is that VNWeb provide a single command that will load the contents of your file (in the format shown below) and populate the variables (whose names appear on the left side of the equal sign) with values shown on the right side of the equal sign.
This is doable.
1) you said that ...
FiletoVar command loads all content of a file into 1 variable.
... so if you can setup a (text) file (say xlate_english.txt) on your server with the following (test) content ...
smGreeting=Hello
smIntroduction=My name is Visual NEO GPT
smAbout=I am your AI Robot
smName=What is your name ?
smHelpTopic=What can I help you with today ?... and then provide me with the url of this file, I will upload a sample .app after I verify my code with it.
2) after I can confirm that this content has been populated into a single variable, I will develop a subroutine that will ...
a) split the variable into an array of items
b) for each item, populate the variables (smGreeting, smIntroduction etc.) with he corresponding values3) You will be able to invoke this subroutine with just one subroutine-command.
Later, if there is wide community interest, the subroutine can be converted into a plugin-command.
Let me know if you are interested.
As I read the various threads in this post, it appears that your requirement has changed somewhat; you are no longer asking for a command like SaveVariables in VNWin (you are text editing this file yourself).
So all you are asking is that VNWeb provide a single command that will load the contents of your file (in the format shown below) and populate the variables (whose names appear on the left side of the equal sign) with values shown on the right side of the equal sign.
This is doable.
1) you said that ...
FiletoVar command loads all content of a file into 1 variable.
... so if you can setup a (text) file (say xlate_english.txt) on your server with the following (test) content ...
smGreeting=Hello
smIntroduction=My name is Visual NEO GPT
smAbout=I am your AI Robot
smName=What is your name ?
smHelpTopic=What can I help you with today ?
... and then provide me with the url of this file, I will upload a sample .app after I verify my code with it.
2) after I can confirm that this content has been populated into a single variable, I will develop a subroutine that will ...
a) split the variable into an array of items
b) for each item, populate the variables (smGreeting, smIntroduction etc.) with he corresponding values
3) You will be able to invoke this subroutine with just one subroutine-command.
Later, if there is wide community interest, the subroutine can be converted into a plugin-command.
Let me know if you are interested.

Quote from luishp on May 13, 2023, 10:58 am@smartmedia once you have loaded the content into a a single variable it's easy to split it to assign vaules to variables.
Take a look at this code and attached sample app (taking @gaev sample text):BeginJS $App.text = `smGreeting=Hello smIntroduction=My name is Visual NEO GPT smAbout=I am your AI Robot smName=What is your name ? smHelpTopic=What can I help you with today ?`; lines = $App.text.split('\n'); for (line of lines) { parts = line.split('='); variableName = parts[0]; variableValue = parts[1]; $App[variableName] = variableValue; } EndJS
@smartmedia once you have loaded the content into a a single variable it's easy to split it to assign vaules to variables.
Take a look at this code and attached sample app (taking @gaev sample text):
BeginJS
$App.text = `smGreeting=Hello
smIntroduction=My name is Visual NEO GPT
smAbout=I am your AI Robot
smName=What is your name ?
smHelpTopic=What can I help you with today ?`;
lines = $App.text.split('\n');
for (line of lines) {
parts = line.split('=');
variableName = parts[0];
variableValue = parts[1];
$App[variableName] = variableValue;
}
EndJS
Uploaded files:Quote from Gaev on May 13, 2023, 12:56 pm@luishp
When I last posted, I was thinking of using the SetCompVar command, which allows you to do a kind of SetVar with the variable name being dynamically generated from other variables; although the Help file (https://webhelp.visualneo.com/Variables.html) implies that it only works with numeric indices/suffixes, I verified that it also works with alphabetic ones.
@smartmedia
Neither suggestion is a one-command solution, but once these are shown to do what you want, the same code can be wrapped as Functions or Plugins, which only require one command to invoke.
When I last posted, I was thinking of using the SetCompVar command, which allows you to do a kind of SetVar with the variable name being dynamically generated from other variables; although the Help file (https://webhelp.visualneo.com/Variables.html) implies that it only works with numeric indices/suffixes, I verified that it also works with alphabetic ones.
Neither suggestion is a one-command solution, but once these are shown to do what you want, the same code can be wrapped as Functions or Plugins, which only require one command to invoke.

Quote from smartmedia on May 13, 2023, 7:57 pmHi..
At the beginning i was trying to remember what was the commands i used to use in NB, and the User @iretz gave me the answer that was Load - Save Variable command. So now i know that LoadVariables function do what i want but it doesn't work on VNW.
Then i replied to @fkapnist that FiletoVar command loads all content of a file into 1 variable and this is NOT what i want. From that moment @luishp suggested:
BeginJS $App.text = `smGreeting=Hello smIntroduction=My name is Visual NEO GPT smAbout=I am your AI Robot smName=What is your name ? smHelpTopic=What can I help you with today ?`; lines = $App.text.split('\n'); for (line of lines) { parts = line.split('='); variableName = parts[0]; variableValue = parts[1]; $App[variableName] = variableValue; } EndJSchanging the code to load the contains of all ready made file like thisSetVar [language] 0 FileToVar "https://servicefinder.gr/en.txt" [language] BeginJS $App.text = `[language]`; .......it not seems to work for me.@gaevI created a file called en.txt in my server (https://servicefinder.gr/en.txt)the file has the text you have suggested. So i am w8 to check your solution two.Thanks all for you help.. I really appreciated..
Hi..
At the beginning i was trying to remember what was the commands i used to use in NB, and the User @iretz gave me the answer that was Load - Save Variable command. So now i know that LoadVariables function do what i want but it doesn't work on VNW.
Then i replied to @fkapnist that FiletoVar command loads all content of a file into 1 variable and this is NOT what i want. From that moment @luishp suggested:
BeginJS
$App.text = `smGreeting=Hello
smIntroduction=My name is Visual NEO GPT
smAbout=I am your AI Robot
smName=What is your name ?
smHelpTopic=What can I help you with today ?`;
lines = $App.text.split('\n');
for (line of lines) {
parts = line.split('=');
variableName = parts[0];
variableValue = parts[1];
$App[variableName] = variableValue;
}
EndJS
SetVar [language] 0 FileToVar "https://servicefinder.gr/en.txt" [language] BeginJS $App.text = `[language]`; .......
Quote from Gaev on May 13, 2023, 11:56 pm@smartmedia
Although the Browser returns the contents of the file at address (url) of https://servicefinder.gr/en.txt, when I try and do a FileToVar, I find this error message under Inspect >>> Console
ps://servicefinder.gr/en.txt' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
servicefinder.gr/en.txt:1Failed to load resource: net::ERR_FAILED
I get the same error message when I compile my sample App and then try and run it from localhost.
This has nothing to do with the App or VisualNEOWeb; you have to setup your server to allow this file to be accessed by anyone.
In an earlier post, you said "FiletoVar command loads all content of a file into 1 variable"; can you advise how you managed to achieve this ? ... did you compile the App and run it from localhost ?
Let me know when you have setup your server to do so.
I have attached a sample App that bypasses the FileToVar command; instead, I use SetVar to populate the variable that FileToVar would have placed in a single variable, and shows how this received data can be split (and split again) in order to populate the variables.
In this version, all the code is in a Function called setupVariables (it is invoked with a single script command of the same name) in the click section of the button labelled Just Do It.
If you intend to use this functionality only in a single App, then leaving the code as a Function is the way to go; but if you anticipate deploying this functionality in many Apps, turning this code into a plugin command is the better way to go.
@luishp
While developing the (NeoScript) Function for smartMedia, I discovered a deficiency with the StrParse command; it does not return the length (i.e. number of items) of the resulting array.
The Help file (https://webhelp.visualneo.com/Strings1.html) says ...
The count variable will be set to the number of elements stored in the array
... but I could not find a way to obtain this number (perhaps I am having a Senior moment) ... is there a NeoScript command for this ?
In the mean time, I used a BeginJS/EndJS code block to get this value.
Although the Browser returns the contents of the file at address (url) of https://servicefinder.gr/en.txt, when I try and do a FileToVar, I find this error message under Inspect >>> Console
ps://servicefinder.gr/en.txt' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
servicefinder.gr/en.txt:1
Failed to load resource: net::ERR_FAILED
I get the same error message when I compile my sample App and then try and run it from localhost.
This has nothing to do with the App or VisualNEOWeb; you have to setup your server to allow this file to be accessed by anyone.
In an earlier post, you said "FiletoVar command loads all content of a file into 1 variable"; can you advise how you managed to achieve this ? ... did you compile the App and run it from localhost ?
Let me know when you have setup your server to do so.
I have attached a sample App that bypasses the FileToVar command; instead, I use SetVar to populate the variable that FileToVar would have placed in a single variable, and shows how this received data can be split (and split again) in order to populate the variables.
In this version, all the code is in a Function called setupVariables (it is invoked with a single script command of the same name) in the click section of the button labelled Just Do It.
If you intend to use this functionality only in a single App, then leaving the code as a Function is the way to go; but if you anticipate deploying this functionality in many Apps, turning this code into a plugin command is the better way to go.
While developing the (NeoScript) Function for smartMedia, I discovered a deficiency with the StrParse command; it does not return the length (i.e. number of items) of the resulting array.
The Help file (https://webhelp.visualneo.com/Strings1.html) says ...
The count variable will be set to the number of elements stored in the array
... but I could not find a way to obtain this number (perhaps I am having a Senior moment) ... is there a NeoScript command for this ?
In the mean time, I used a BeginJS/EndJS code block to get this value.
Uploaded files: