Page 1 of 3

Append variable to an array ?

Posted: 22 Dec 2023 16:38
by MonkeyButt
How do I append a variable to an array; if it is at all possible ?

Code: Select all

foreach($iten,$askusr){
$ccPath = listfolder($iten,input("Folder to Find",,,e,300,300),2,||);
$pArray[] = array($ccPath);

Re: Append variable to an array ?

Posted: 22 Dec 2023 17:18
by highend
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;
    }

Re: Append variable to an array ?

Posted: 22 Dec 2023 17:42
by admin
:eh: I wonder why it shouldn't be possible, it's easy. I'll try it in the next beta.

Re: Append variable to an array ?

Posted: 22 Dec 2023 19:20
by highend
Regarding the beta: This isn't any different from using explode() which worked already before that version?

That is not an array that is filled with other arrays (so called multi-dimensional arrays)...

For example (choose your own folder(s) which at least have one subfolder:

Code: Select all

    $folders = "D:\Users\Highend\Development\C#|D:\Users\Highend\Development\Dart";

    $i = 0;
    foreach($folder, $folders, "|", "e") {
        $subs = listfolder($folder, , 2, "||");
        explode($toAdd, $subs, "||", "e");
        $pArray[$i] = $toAdd;
        $i += 1;
    }
No, that doesn't work :masked:

Re: Append variable to an array ?

Posted: 22 Dec 2023 19:28
by admin
It is fulfilling a very natural expectation. And array() can do some stuff that explode() can't.

Nope, multi-dimensional arrays are not supported.

Re: Append variable to an array ?

Posted: 22 Dec 2023 19:50
by highend
It is fulfilling a very natural expectation
It was not the expectation from the op :biggrin:

Re: Append variable to an array ?

Posted: 22 Dec 2023 19:51
by admin
Well, it was mine. :)

Re: Append variable to an array ?

Posted: 23 Dec 2023 01:26
by MonkeyButt
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;
    }
👍 Except when I

Code: Select all

echo $pArray
no list is show ?

Re: Append variable to an array ?

Posted: 23 Dec 2023 01:49
by highend
Implode the array to see all entries?
text implode($pArray);

or an index to see a specific one^^

Re: Append variable to an array ?

Posted: 23 Dec 2023 02:52
by MonkeyButt
highend wrote: 23 Dec 2023 01:49 Implode the array to see all entries?
text implode($pArray);

or an index to see a specific one^^
Impode() is sorta working, I'm getting the index value instead of the actual name of the folder ?

Re: Append variable to an array ?

Posted: 24 Dec 2023 03:48
by MonkeyButt

Code: Select all

text implode($pArray,$i,||,,)
Result;

Code: Select all

implode(,0,||,,) goto B:\~~~~~
Why am I getting the function name in my output; I've read the function arguments half a dozen times I can't understand what I'm doing wrong ?

Re: Append variable to an array ?

Posted: 27 Dec 2023 11:58
by admin
Well, you have not read enough.

1) What do you want to achieve?
2) Show not just one line out of context but something that's copy-and-pastable for testing.

Re: Append variable to an array ?

Posted: 27 Dec 2023 16:13
by MonkeyButt
admin wrote: 27 Dec 2023 11:58 Well, you have not read enough.

1) What do you want to achieve?
2) Show not just one line out of context but something that's copy-and-pastable for testing.
I want to show the list without the output showing the actual implode() function within the output.

Code: Select all

$i=0
foreach($iten,$askusr){
//$ccPath = listfolder($iten,input("Folder to Find",,,e,300,300),2,||);
$ccPath = listfolder($iten,*,2,||);
$pArray[$i] = $iten;
$gPath = pathreal($ccPath);
text implode($pArray,$i,||,,)
This is the output, the impode() function is also being put as the output ?
implode(,0,||,,) goto B:\Cloud\Sync\.autosave||B:\Cloud\Sync\DesignerPaths||B:\Cloud\Sync\FF~~~~~~~
I hope this helps.

Re: Append variable to an array ?

Posted: 27 Dec 2023 16:35
by admin
Cannot work with this. You're wasting my time. Sorry, I'm out.

Re: Append variable to an array ?

Posted: 27 Dec 2023 16:43
by MonkeyButt
The script is not complete, I just wanted to know why I'm setting the implode() function in the printed output; doesn't make sense. I was hoping you would maybe know based on those lines of code. That is where the main problem exists; but if you want here is the whole code.

Code: Select all

$askusr = inputfolder("C:\","Choose Source Folder");
//$mvfld = input("Enter folder ",,,e,500,400); // Destination Folder for which the files are to be moved too from the Source Folder
$i = 0;
foreach($iten,$askusr){
//$ccPath = listfolder($iten,input("Folder to Find",,,e,300,300),2,||);
$ccPath = listfolder($iten,*,2,||);
$pArray[$i] = $iten;
$gPath = pathreal($ccPath);
text implode($pArray,$i,||,,)
goto $gPath;
$i += 1;
}