Post your questions and help other users.
	Moderator: Martin
			
		
		
			- 
				
								Martin							
- Posts: 4468
- Joined: 09 Nov 2012 14:23
						
						
													
							
						
									
						Post
					
								by Martin » 14 Jul 2014 16:13
			
			
			
			
			Hi,
Action 
Write to File can not directly insert a line on a specific line. You would have to split the file into a list of lines, insert the line and write the lines to a file again. You can find some examples of splitting a file into lines on the 
examples page.
You can also use the split mechanism to check if a text file contains a particular text on a line. Something like this should work in a condition 
Expression:
Code: Select all
text_file = "line1\nline2\nline3\nline4";
lines = split(text_file, "\\n");
line3=getElement(lines, 2);
contains(line3, "line");
The last line of condition 
Expression determines whether the condition is true or false.
Regards,
Martin
 
		 
				
		
		 
	 
	
				
		
		
			- 
				
																			 hcporto
- Posts: 10
- Joined: 09 Jun 2014 21:14
						
						
													
							
						
									
						Post
					
								by hcporto » 01 Aug 2014 17:01
			
			
			
			
			Thanks Martin.
How can i get the value inside a text file and turn it into a global_variable to be used on other scripts?
			
									
									
						 
		 
				
		
		 
	 
	
				
		
		
			- 
				
								Martin							
- Posts: 4468
- Joined: 09 Nov 2012 14:23
						
						
													
							
						
									
						Post
					
								by Martin » 02 Aug 2014 07:03
			
			
			
			
			Hi,
Use a global variable in action Init Variable Text File. The action could look like this: Init Variable Text File: /storage/emulated/0/file.txt to global_text_file
Other flows will have access to the global variable global_text_file as soon as the action is executed. It's usually better to read the contents of a file only into a local variable, especially when the text file is large.
Could you explain what you are trying to achieve, maybe there's a better solution to the problem?
Regards,
Martin