ASP.NET WebForms application I have a folder Scripts where there are
This TXT file contains some values, that I can insert on it how I want.
For example, one value for row:
or in comma separated values:
Now my question is:
as many variables as the values in the TXT file?
For example, in this case, something like this:
var myValue01 = Value01;
var myValue02 = Value02;
var myValue03 = Value03;
Thanks in advance for every idea.
Welcome to this forum.
Could be fine.
The important is then I can put these values in variables.
To read the file you can use the Fetch API:
or the older XMLHttpRequest:
Why can’t you leave the values in an array?
Ok, I can leave in an array.
Because then I have to use these values in some IF statements.
For example, this is one if my IF
if (DataSourceNameVal == SRC_FOCUS
|| DataSourceNameVal == SRC_VAX
|| (DataSourceNameVal == Value01 && SMSExpenseId.startsWith("A-"))
Instead of Value01
I should replace with all values from the array.
I am not fully understanding what you are trying to do, but I understand there can be any number of values within your .txt file.
I suggest you:
- Read the .txt file into a string using
fetch or X
- Split the string into a string array using the string
- Get the length of the array using the string
- Put your ‘
if’ statement within a loop;
- Instead of
Value01 within your ‘if’ condition, use
Value[index] to get a value from the array (as a string) where
Value is the string array and
index is the loop index.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.