
Quote from joferar333 on June 23, 2023, 11:18 pmHi! @luishp,@Darbdenral,@vadim,@rcohen,@asmat
ENGLISH
Hello people, let's see if someone can give me a hand, the truth is that I have no idea how to work with arrays and from what I see to achieve this I think it goes that way...
I've seen some examples of routines and scripts found on the forum but I can't adapt them.
the idea is simple I have a file called utiles.txt in the domain
That file contains 54 lines and I need to read that file and have each of the lines become a variable that the app uses.Uploading the file is not a problem I do it with phpfiletovar
but what I don't know is how to read each line once loaded so that each line becomes a variable...From already thank you very much
ESPAÑOL
Hola gente a ver si alguien me puede dar una mano, la verdad que no tengo idea de como trabajar con arrays y por lo que veo para lograr esto creo que va por ahi...
He visto algunos ejemplos de rutinas y script que se encuentran en el foro pero no puedo adaptarlos.
la idea es simple tengo en el dominio un archivo llamado utiles.txt
Ese archivo contine 54 lineas y necesito leer ese archivo y que cada una de las lineas se convierta en una variable que usa la app.Cargar el archivo no es problema lo hago con phpfiletovar
pero no lo que se es como leer una vez cargado cada linea para que cada linea se convierta en una variable...Desde ya muchas gracias
Hi! @luishp,@Darbdenral,@vadim,@rcohen,@asmat
ENGLISH
Hello people, let's see if someone can give me a hand, the truth is that I have no idea how to work with arrays and from what I see to achieve this I think it goes that way...
I've seen some examples of routines and scripts found on the forum but I can't adapt them.
the idea is simple I have a file called utiles.txt in the domain
That file contains 54 lines and I need to read that file and have each of the lines become a variable that the app uses.
Uploading the file is not a problem I do it with phpfiletovar
but what I don't know is how to read each line once loaded so that each line becomes a variable...
From already thank you very much
ESPAÑOL
Hola gente a ver si alguien me puede dar una mano, la verdad que no tengo idea de como trabajar con arrays y por lo que veo para lograr esto creo que va por ahi...
He visto algunos ejemplos de rutinas y script que se encuentran en el foro pero no puedo adaptarlos.
la idea es simple tengo en el dominio un archivo llamado utiles.txt
Ese archivo contine 54 lineas y necesito leer ese archivo y que cada una de las lineas se convierta en una variable que usa la app.
Cargar el archivo no es problema lo hago con phpfiletovar
pero no lo que se es como leer una vez cargado cada linea para que cada linea se convierta en una variable...
Desde ya muchas gracias

Quote from rcohen on June 23, 2023, 11:51 pmHi @joferar333,
Think of an array as pieces of data, separated by a character called the delimiter. The most common delimiter is the comma, but in the case of commandline variables, then a space would be the delimiter.
What you would do is process the long string containing your dataset, and you would chop them down into their separate elements, and the command that will do this is StrParse command. The following is the format that the wizard will generate for you. After running this, you will have one variable in the form of one variable per element in the format of [Element[number]] And so variable [Element1] will contain the first value, [Element2] will contain the next, etc.
StrParse "[TheStringToParse]" "[DeLimiter]" "[element]" "[TotalElements]"
And you do this by setting up a loop. If you need help with setting up a loop, just ask.
Cheers
Hi @joferar333,
Think of an array as pieces of data, separated by a character called the delimiter. The most common delimiter is the comma, but in the case of commandline variables, then a space would be the delimiter.
What you would do is process the long string containing your dataset, and you would chop them down into their separate elements, and the command that will do this is StrParse command. The following is the format that the wizard will generate for you. After running this, you will have one variable in the form of one variable per element in the format of [Element[number]] And so variable [Element1] will contain the first value, [Element2] will contain the next, etc.
StrParse "[TheStringToParse]" "[DeLimiter]" "[element]" "[TotalElements]"
And you do this by setting up a loop. If you need help with setting up a loop, just ask.
Cheers

Quote from joferar333 on June 24, 2023, 12:01 amThanks @rcohen
thanks for your answer, what I can't understand is when you say the long string separated by a character...
My file does not have any separation, it is only written line by line...I can't figure out how to carry it out
example the file contains
util.txt
volunteer firefighters 5635555
highway police 568999
cemetery 4587888that is to say, each of those lines I need to convert into a variable
The truth is that I'm complicated because I can't find an example, the ones that are there and I saw take the data already written in the publication internally and instead I need to read them from the file....
Thanks @rcohen
thanks for your answer, what I can't understand is when you say the long string separated by a character...
My file does not have any separation, it is only written line by line...
I can't figure out how to carry it out
example the file contains
util.txt
volunteer firefighters 5635555
highway police 568999
cemetery 4587888
that is to say, each of those lines I need to convert into a variable
The truth is that I'm complicated because I can't find an example, the ones that are there and I saw take the data already written in the publication internally and instead I need to read them from the file....

Quote from rcohen on June 24, 2023, 12:36 amBelieve it or not, even a line by line file is an array, only their delimiter is the line feed or paragraph markup, expressed in VNW by [#10] and [#13]. You will have to test with your file to see if it response to one, the other, or both.
So you can use the build in array example, but replace the delimiter as explained above, and populate the variable with your file contents using.
But a much better idea for you would be reading out of the file one line at a time. This is a basic loop operation to accomplish this.
FileLen "[TheFile]" "[TotalLines]" Loop "1" "[TotalLines]" "[LineNumber]" FileRead "[TheFile]" "[LineNumber]" "[Element[LineNumber]]" ...notice the double closed bracket in the above line. This closes both open brackets preceeding it. .. If you need to do something WITH [Element[LineNumber]] this is the area to do that. Endloop ... If you are populating a VERY large file, this could put a drain on your system resources (RAM) and may therefore take a LONG time. The loop will perform once per line of data in your file.You may otherwise consider rather than creating one variable per line, to do whatever you're doing to do with those, during the looping process, as to avoid building up a huge RAM overhead.
Believe it or not, even a line by line file is an array, only their delimiter is the line feed or paragraph markup, expressed in VNW by [#10] and [#13]. You will have to test with your file to see if it response to one, the other, or both.
So you can use the build in array example, but replace the delimiter as explained above, and populate the variable with your file contents using.
But a much better idea for you would be reading out of the file one line at a time. This is a basic loop operation to accomplish this.
FileLen "[TheFile]" "[TotalLines]" Loop "1" "[TotalLines]" "[LineNumber]" FileRead "[TheFile]" "[LineNumber]" "[Element[LineNumber]]" ...notice the double closed bracket in the above line. This closes both open brackets preceeding it. .. If you need to do something WITH [Element[LineNumber]] this is the area to do that. Endloop ... If you are populating a VERY large file, this could put a drain on your system resources (RAM) and may therefore take a LONG time. The loop will perform once per line of data in your file.
You may otherwise consider rather than creating one variable per line, to do whatever you're doing to do with those, during the looping process, as to avoid building up a huge RAM overhead.

Quote from joferar333 on June 24, 2023, 12:47 amThanks friend.. @rcohen
But what you tell me applies to visual neo win there if I know how to do it by reading line by line the issue is that what I am needing is to use neovisual WEB
Thanks friend.. @rcohen
But what you tell me applies to visual neo win there if I know how to do it by reading line by line the issue is that what I am needing is to use neovisual WEB

Quote from rcohen on June 24, 2023, 12:49 amMy apologies. I should have looked first to see which forum I was in, but because I was tagged, I assume this was VN for Windows.
Sorry about the misunderstanding.
My apologies. I should have looked first to see which forum I was in, but because I was tagged, I assume this was VN for Windows.
Sorry about the misunderstanding.

Quote from joferar333 on June 24, 2023, 1:24 am@rcohen friend not problem thank any mode
Best Regards
@rcohen friend not problem thank any mode
Best Regards

Quote from roccocogliano on June 26, 2023, 9:58 amHi,
To mark line endings in text files, the following characters are used:
Unix/Linux file systems use newlines (\n).
MacOS uses carriage-returns (\r).
Windows uses a carriage-return followed by a newline (\r\n).
So first check the line terminator of your file.Assuming to use '\n' as terminator, if you have content of your text file (utiles.txt) in a variable called [textFileContent] (for example) just parse the text.
. text parsing using '\n' as separator. in the [arrRowsOfTextFile] array there will be all the lines of the text file StrParse "[textFileContent]" "\n" [arrRowsOfTextFile] .you will have first row in variable [arrRowsOfTextFile(0)] jsalert([arrRowsOfTextFile(0)]) .you will have second row in variable [arrRowsOfTextFile(1)] jsalert([arrRowsOfTextFile(1)]) .... and so on until the end of the array... THAT'S ALL!!!
Hi,
To mark line endings in text files, the following characters are used:
Unix/Linux file systems use newlines (\n).
MacOS uses carriage-returns (\r).
Windows uses a carriage-return followed by a newline (\r\n).
So first check the line terminator of your file.
Assuming to use '\n' as terminator, if you have content of your text file (utiles.txt) in a variable called [textFileContent] (for example) just parse the text.
. text parsing using '\n' as separator. in the [arrRowsOfTextFile] array there will be all the lines of the text file StrParse "[textFileContent]" "\n" [arrRowsOfTextFile] .you will have first row in variable [arrRowsOfTextFile(0)] jsalert([arrRowsOfTextFile(0)]) .you will have second row in variable [arrRowsOfTextFile(1)] jsalert([arrRowsOfTextFile(1)]) .... and so on until the end of the array... THAT'S ALL!!!