Multi Commander > Support and Feedback

LoadArray

(1/1)

pncdaspropagandas:
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

AlanJB:
Try:

@var $temp_scrap_file = ".\\Config\\Scrap\\scrap.txt";
@var $old_items[] = LoadArray($temp_scrap_file);

pncdaspropagandas:
you killed it  :)

sorry, i'm not used to declare @var

AlanJB:
Did it work OK?


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

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 :)

pncdaspropagandas:
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.

Navigation

[0] Message Index

Go to full version