@@ -143,7 +143,7 @@ void RegisterCommands(PLUG_INITSTRUCT* initStruct)
143143 registerCommand (" ReadStr" , ReadStr, true );
144144 registerCommand (" ReadMem" , ReadMem, true );
145145 registerCommand (" Write2Mem" , Write2Mem, true );
146-
146+
147147
148148 registerCommand (" BPxx" , BPxx, true );
149149 registerCommand (" bpcx" , bpcx, true );
@@ -162,7 +162,7 @@ void RegisterCommands(PLUG_INITSTRUCT* initStruct)
162162 registerCommand (" ResizeArray" , ResizeArray, false );
163163 registerCommand (" GetArraySize" , GetArraySize, false );
164164 registerCommand (" Write2File" , Write2File, false );
165- registerCommand (" ReadFile" , ReadFile, false );
165+ registerCommand (" ReadFile" , ReadFile, false );
166166 registerCommand (" inputbox" , InputBox, false );
167167 registerCommand (" GetdesCallJmp" , GetdesCallJmp, true );
168168
@@ -1292,34 +1292,34 @@ static bool Write2Mem(int argc, char* argv[]) { //Write2Mem(duint address,variab
12921292 return false ;
12931293 }
12941294
1295- String^ Data= StrAnalyze (arguments[1 ],VarType::str,false );
1295+ String^ Data = StrAnalyze (arguments[1 ], VarType::str, false );
12961296 Data = reMoveSpaces (Data);
12971297 duint tempAddr = Str2duint (AddrIntValue);
12981298 if (Data->Length <= 1 ) {
12991299 _plugin_logputs (Str2ConstChar (Environment::NewLine + " Byte length is wrong" ));
13001300 return false ;
13011301 }
1302- if ((Data->Length % 2 !=0 )) { // if length is odd
1302+ if ((Data->Length % 2 != 0 )) { // if length is odd
13031303 Data = Data->Substring (0 , Data->Length - 1 );
1304- _plugin_logputs (Str2ConstChar (Environment::NewLine + " Byte length has truncated by 1 " ));
1304+ _plugin_logputs (Str2ConstChar (Environment::NewLine + " Byte length has truncated by 1 " ));
13051305 }
1306- for (int i = 0 ; i < Convert::ToInt32 (Data->Length ); i=i+ 2 )
1306+ for (int i = 0 ; i < Convert::ToInt32 (Data->Length ); i = i + 2 )
13071307 {
13081308 String^ Byte_ = Data->Substring (i, 2 );
13091309 String^ Byte_IntValue;
13101310 if (CheckHexIsValid (Byte_, Byte_IntValue) == 0 ) {
13111311 _plugin_logputs (Str2ConstChar (Environment::NewLine + " Byte is not hex value " ));
13121312 return false ;
13131313 }
1314- unsigned char byte_ =Convert::ToByte (Byte_IntValue);
1315- bool suc= Script::Memory::WriteByte (tempAddr, byte_);
1314+ unsigned char byte_ = Convert::ToByte (Byte_IntValue);
1315+ bool suc = Script::Memory::WriteByte (tempAddr, byte_);
13161316 if (!suc) {
13171317 _plugin_logputs (Str2ConstChar (Environment::NewLine + " Couldn't write to memory " ));
13181318 return false ;
13191319 }
13201320 tempAddr = tempAddr + 1 ;
1321- }
1322- return true ;
1321+ }
1322+ return true ;
13231323 }
13241324 default :
13251325 _plugin_logputs (Str2ConstChar (Environment::NewLine + " worng arguments" ));
@@ -1923,16 +1923,16 @@ static bool ReadFile(int argc, char* argv[]) { // ReadFile(array var , path )
19231923 GetArg (charPTR2String (argv[0 ]), arguments);
19241924 switch ((arguments->Count ))
19251925 {
1926- case 3 : {
1926+ case 2 : {
19271927 String^ pathfile;
1928- if (arguments[0 ]->StartsWith (" $" )) { // / that mesn its variable
1929- String^ path_ = StrAnalyze (arguments[0 ], VarType::str);
1928+ if (arguments[1 ]->StartsWith (" $" )) { // / that mesn its variable
1929+ String^ path_ = StrAnalyze (arguments[1 ], VarType::str);
19301930 if (!path_->Contains (" NULL/" )) {
19311931 if (!path_->EndsWith (" .txt" )) {
19321932 _plugin_logputs (Str2ConstChar (Environment::NewLine + " not ended with .txt" ));
19331933 return false ;
19341934 }
1935- if (!IO::Directory ::Exists (IO::Path::GetDirectoryName ( path_) )) {
1935+ if (!IO::File ::Exists (path_)) {
19361936 _plugin_logputs (Str2ConstChar (Environment::NewLine + " worng path" ));
19371937 return false ;
19381938 }
@@ -1942,16 +1942,16 @@ static bool ReadFile(int argc, char* argv[]) { // ReadFile(array var , path )
19421942 _plugin_logputs (Str2ConstChar (Environment::NewLine + " worng path" ));
19431943 return false ;
19441944 }
1945- pathfile = StrAnalyze (arguments[0 ], VarType::str);
1945+ pathfile = StrAnalyze (arguments[1 ], VarType::str);
19461946 }
19471947 else
19481948 {
1949- if (!arguments[0 ]->EndsWith (" .txt" )) {
1949+ if (!arguments[1 ]->EndsWith (" .txt" )) {
19501950 _plugin_logputs (Str2ConstChar (Environment::NewLine + " not ended with .txt" ));
19511951 return false ;
19521952 }
1953- if (arguments[0 ]->Contains (" \\ " )) { // / check it if it's path file
1954- if (!IO::Directory ::Exists (IO::Path::GetDirectoryName ( arguments[0 ]) )) {
1953+ if (arguments[1 ]->Contains (" \\ " )) { // / check it if it's path file
1954+ if (!IO::File ::Exists (arguments[1 ] )) {
19551955 _plugin_logputs (Str2ConstChar (Environment::NewLine + " worng path" ));
19561956 return false ;
19571957 }
@@ -1961,11 +1961,28 @@ static bool ReadFile(int argc, char* argv[]) { // ReadFile(array var , path )
19611961 _plugin_logputs (Str2ConstChar (Environment::NewLine + " worng path" ));
19621962 return false ;
19631963 }
1964- pathfile = arguments[0 ];
1964+ pathfile = arguments[1 ];
19651965 }
19661966
1967-
1968- return Write2File_ (pathfile, Str2bool (arguments[1 ]), arguments[2 ]);
1967+ int indexofVar = 0 ; String^ retvartype = " " ; int arrayLength;
1968+ if ((Varexist (arguments[0 ]->Trim (), retvartype, indexofVar, arrayLength)) && (arguments[0 ]->Trim ()->StartsWith (" $" ))) {
1969+ if (retvartype == " array" ) {
1970+ array<String^>^ Lines = IO::File::ReadAllLines (pathfile);
1971+ for (int i = 0 ; i < Lines->Length ; i++)
1972+ {
1973+ int arrLeng = ScriptFunList::VarList[indexofVar]->arrayLength ;
1974+ ScriptFunList::VarList[indexofVar]->varvalue [arrLeng - 1 ]=Lines[i];
1975+ if (i !=Lines->Length -1 )
1976+ ScriptFunList::VarList[indexofVar]->ResizeArr (1 );
1977+ }
1978+ }
1979+ else
1980+ {
1981+ _plugin_logputs (Str2ConstChar (Environment::NewLine + " variable not array" ));
1982+ return false ;
1983+ }
1984+ }
1985+ return true ;
19691986 }
19701987 default :
19711988 _plugin_logputs (Str2ConstChar (Environment::NewLine + " worng arguments" ));
0 commit comments