Multi Commander Support Forum

Multi Commander => Support and Feedback => Topic started by: pncdaspropagandas on January 27, 2017, 16:47:06

Title: LoadArray
Post by: pncdaspropagandas on January 27, 2017, 16:47:06
Hi,

I'm implementing a scrap area that I can Add/Remove files to it.

When I execute the command:
@var $temp_scrap_file = ".\Config\Scrap\scrap.txt";
$old_items = LoadArray($temp_scrap_file);
if the txt file is empty MC immediately closes

I will do a verification if the file is empty prior to LoadArray, but I would like just to let you guys now

Thanks
Title: Re: LoadArray
Post by: AlanJB on January 27, 2017, 17:33:28
Try:

@var $temp_scrap_file = ".\\Config\\Scrap\\scrap.txt";
@var $old_items[] = LoadArray($temp_scrap_file);
Title: Re: LoadArray
Post by: pncdaspropagandas on January 27, 2017, 17:45:31
you killed it  :)

sorry, i'm not used to declare @var
Title: Re: LoadArray
Post by: AlanJB on January 28, 2017, 00:25:37
Did it work OK?

Quote
sorry, i'm not used to declare @var

Me either - I used a language that didn't use scripting at all , but it all makes sense! Trust Mathias ;)

(BTW Jungle is the scripting guru here [certainly not me] - he'll always put you right)

MC is a damned good tool; learn the syntax (and take a little time to learn the difference between MultiScript & Custom Commands) and it all hangs together :)
Title: Re: LoadArray
Post by: pncdaspropagandas on January 29, 2017, 03:52:26
I'm not sure if it did work or not because I found out after that there are more factors involved. I was saving the scrap file as Unicode  UTF8 (SaveArray). If the array is empty, the created file uses BOM I think, and that writes some bytes at the file although the Notepad++ interface doesn't show nothing. You can see those bytes using a Hex Editor (I use a Notepad++ addon)

After all I implemented an empty file check to avoid loading an empty file and used ANSI to write the file and avoid the BOM bytes.

Yes, I'm loving MC and I did a Notepad++ User Defined Language to support MC Script. I'm posting it on User Contributed Content.