Are you sure this is how you iterate though an Array. I tried this and it should atleast give me one index of 0; instead nothing ?highend wrote: ↑22 Dec 2023 17:18 Adding to an array is possible but it seems arrays can't contain subarrays...
Code: Select all
$i = 0; foreach($iten,$askusr){ $ccPath = listfolder($iten,input("Folder to Find",,,e,300,300),2,||); $pArray[$i] = $ccPath; $i += 1; }
Append variable to an array ?
-
- Posts: 19
- Joined: 21 Dec 2023 01:31
Re: Append variable to an array ?
Re: Append variable to an array ?
As if I hadn't written a single post in this thread...
Ofc it's possible to iterate this way. But you are (as always) providing NO DATA at all so I won't spend any more time on this
Ofc it's possible to iterate this way. But you are (as always) providing NO DATA at all so I won't spend any more time on this
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de
-
- Posts: 19
- Joined: 21 Dec 2023 01:31
Re: Append variable to an array ?
I have provided data in previous post; why post the same thing twice and what is wrong with some theory, nothing.
-
- Posts: 19
- Joined: 21 Dec 2023 01:31
Re: Append variable to an array ?
My original question was to append a variable to an array.
HighEnd mentioned to initiate the variable outside of the forEach loop, then within the forEach loop iterate over that variable.
One should be able to take that information and add to any code that they want to append a variable to an array; which I did but is it not working. Instead of trying to help; he just follows the administrators path and decides to ignore the post, what kind of garbage is going on here cause it's strange. Do you want people to script in XY or is it just for a select few cause that would make no sense considering anyone can buy XY and script.
HighEnd mentioned to initiate the variable outside of the forEach loop, then within the forEach loop iterate over that variable.
Code: Select all
$i = 0;
foreach($iten,$askusr){
$ccPath = listfolder($iten,input("Folder to Find",,,e,300,300),2,||);
$pArray[$i] = $ccPath;
$i += 1;
}
Re: Append variable to an array ?
A bit rich of you to ask what is going on here in your post #17 and question the helpfulness of long standing forum members who have helped countless users over the years.
You post snippets of your code without any explanation what the variables at the start of your snippet contain and then expect us to come up with solutions to fix your code.
Firstly read the help on the commands you want to use carefully and, if you still need help, provide the full code and a detailed description of what you are trying to achieve with it.
Switching on step mode and checking the contents of your variables when your script fails might also be a good idea.
You post snippets of your code without any explanation what the variables at the start of your snippet contain and then expect us to come up with solutions to fix your code.
Firstly read the help on the commands you want to use carefully and, if you still need help, provide the full code and a detailed description of what you are trying to achieve with it.
Switching on step mode and checking the contents of your variables when your script fails might also be a good idea.
Ralph
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)
-
- Posts: 19
- Joined: 21 Dec 2023 01:31
Re: Append variable to an array ?
If the code doesn't make sense to you; that is because it's not complete. In the fifth line down I have a variable called $vArray which is an array which I have a variable assigned as mentioned by Highend so that each path gets assigned a index value. Although when I want to return the index value of 3 the output is the array variable with the number three in other words; $vArray[3] instead of whatever index path that index should have had assigned to it.RalphM wrote: ↑03 Jan 2024 06:20 A bit rich of you to ask what is going on here in your post #17 and question the helpfulness of long standing forum members who have helped countless users over the years.
You post snippets of your code without any explanation what the variables at the start of your snippet contain and then expect us to come up with solutions to fix your code.
Firstly read the help on the commands you want to use carefully and, if you still need help, provide the full code and a detailed description of what you are trying to achieve with it.
Switching on step mode and checking the contents of your variables when your script fails might also be a good idea.
I understand what Highend did, what I don't understand is why it's not assigning an index to each path so I can return the index and I get the path for whatever index is assigned to that path. Once again, if the code doesn't make sense to you it's not complete.
Code: Select all
$askusr = inputfolder("C:\","Choose Source Folder");
$i=0;
foreach($iten,$askusr){
foreach($nArray,$iten){
$listpane = listpane(a,*,2,,);
$vArray[$i] = array($listpane);
echo $vArray[3];
};
};
$ccPath = listfolder($iten,input("Folder to Find",,,e,300,300),1);
$pArray[$i] = $ccPath;
$i += 1;
$gPath = pathreal($ccPath);
Re: Append variable to an array ?
Are you f*** serious?
You've been told to activate "Syntax Checking". You didn't
You've been told that $askusr will only contain one item, iterating over one item is... <no comment>
And now you add another loop inside that ALSO loops over a single item???
No $i incrementation inside the loop: $vArray would always get assigned <something> at index 0^^
$vArray[3] = Always empty
You've been told that arrays in arrays aren't possible and you're still trying to assign it
listpane() on a chosen folder? If you are already inside the folder you wouldn't have to choose it first
If not, it's totally different data
The code gets worse every time
You have absolutely NO clue what you're doing here.
Learn basic scripting first and if you don't want to do that, stop scripting^^
It's leading nowhere...
You've been told to activate "Syntax Checking". You didn't
You've been told that $askusr will only contain one item, iterating over one item is... <no comment>
And now you add another loop inside that ALSO loops over a single item???
No $i incrementation inside the loop: $vArray would always get assigned <something> at index 0^^
$vArray[3] = Always empty
You've been told that arrays in arrays aren't possible and you're still trying to assign it
listpane() on a chosen folder? If you are already inside the folder you wouldn't have to choose it first
If not, it's totally different data
The code gets worse every time
You have absolutely NO clue what you're doing here.
Learn basic scripting first and if you don't want to do that, stop scripting^^
It's leading nowhere...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de
-
- Posts: 19
- Joined: 21 Dec 2023 01:31
Re: Append variable to an array ?
I know the code was not perfect, I did say that twice in my last message.highend wrote: ↑03 Jan 2024 16:31 Are you f*** serious?
You've been told to activate "Syntax Checking". You didn't
You've been told that $askusr will only contain one item, iterating over one item is... <no comment>
And now you add another loop inside that ALSO loops over a single item???
No $i incrementation inside the loop: $vArray would always get assigned <something> at index 0^^
$vArray[3] = Always empty
You've been told that arrays in arrays aren't possible and you're still trying to assign it
listpane() on a chosen folder? If you are already inside the folder you wouldn't have to choose it first
If not, it's totally different data
The code gets worse every time
You have absolutely NO clue what you're doing here.
Learn basic scripting first and if you don't want to do that, stop scripting^^
It's leading nowhere...
You mention no $i incrementation inside the loop yet you didn't show the initialization of it inside the loop either. Instead of trying to help you just behave like a nasty bugger who just hates anyone who you deem to hate. God willing I hope you don't teach people how to drive, that probably is a nightmare.
Re: Append variable to an array ?
My code showed both^^You mention no $i incrementation inside the loop yet you didn't show the initialization of it inside the loop either
$i = 0;
$i += 1;
Thread closed, as already said: It leads nowhere...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de