NexusFi: Find Your Edge


Home Menu

 





FileAppend function failed


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,232 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

FileAppend function failed

  #1 (permalink)
eronyx
Moldova
 
Posts: 9 since Nov 2017
Thanks Given: 6
Thanks Received: 0

Hi guys

If anyone had something like this or know what to do here please help me out.
Basically I made a copier of strategy orders from multiple windows using GlobalDictionary,
then once there are some changes in any of the strategies I write all the info from GlobalDictionary to a file. Usually this happens once in couple minutes, or once per hour, or once per 15 min.

The code is like this:

 
Code
FileDelete(Filepath);
FileAppend(Filepath, NewGDtoFile);
The 3rd party copies this file and then works with it (this happens once in 2 seconds). Once/twice per day I receive these errors:
 
Code
FileAppend function failed
Event: elsystem.SystemException Unable to create file: C:\Users ............
and it shuts down the strategy right away. Anyway to prevent this?

I tried to do something like this:
 
Code
For Value2 = 0 to 3
	Begin
		Try
			Begin								
				FileAppend(Filepath,NewGDtoFile);				
				Value2 = 3;
		    End;		
		Catch (elsystem.Exception ex)
			Begin						 
				Print(Numtostr(Value2,0)+" File Append Error +" + ex.ToString()+" MSG: "+ex.Message.ToString());				
			End;				
    	End;
    End;
but nothing works - still getting them
does anyone knows how to avoid these situations?

Thank You

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
 
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


Hmm, the catch (elsystem.Exception ex) should work and send you the error message, it should not disable the strategy.
You should try in another directory, create a C:\test directory and create an empty file in it, and avoid the FileDelete.
It can be a lock on the file, maybe the Windows events viewer saw something.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #4 (permalink)
eronyx
Moldova
 
Posts: 9 since Nov 2017
Thanks Given: 6
Thanks Received: 0


sam028 View Post
Hmm, the catch (elsystem.Exception ex) should work and send you the error message, it should not disable the strategy.
You should try in another directory, create a C:\test directory and create an empty file in it, and avoid the FileDelete.
It can be a lock on the file, maybe the Windows events viewer saw something.

in this directory it works fine couple of days then suddenly this happens and catch is not picking up the error, not sure why. There is no logic when it happens - either once a day or once in couple of days randomly.
I use FileDelete since I need to have only few lines there, every-time fresh, without that the file will become big in size.

Do you know a method to write to a file from fresh without deleting it?

Reply With Quote
  #5 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


eronyx View Post
...
Do you know a method to write to a file from fresh without deleting it?

No, there is no EL function for this. It's would be possible using a DLL (using DEFINEDLLFUNC) but it's overkill for this purpose.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
eronyx
Moldova
 
Posts: 9 since Nov 2017
Thanks Given: 6
Thanks Received: 0


sam028 View Post
No, there is no EL function for this. It's would be possible using a DLL (using DEFINEDLLFUNC) but it's overkill for this purpose.

I am trying now the elsystem.io.StreamWriter function and it works without FileDelete - just not sure if I will have that error anymore, waiting for it to see if will crash

do you know any other way to catch all exceptions?

thx for your help

Reply With Quote




Last Updated on February 16, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts