Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    452

    write to txt file help needed !!!

    i dont understand why it doesnt write to txt file !!!

    Code:
    new_contents = Input.GetText("Input1");
    
    if e_Key == 13 then 
    	if(new_contents)then
       		 for i, v in new_contents do
    		    TextFile.WriteFromString("AutoPlay\\Scripts\\history.txt", v.."\r\n", true)
       		 end
    	else
        Dialog.Message("Error", "No Text");
    	end
    end

  2. #2
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Because Input.GetText doesn't return a table, but a string. So looping through it won't work unless you convert it to a table.

    From input.
    Code:
    if(e_Key==13)then -- Enter is pressed
    	if(new_contents~="")then -- Making sure the new content is nog empty!
    		TextFile.WriteFromString("Autoplay\\Scripts\\history.txt", new_contents.."\r\n", true);
    	else
    		Dialog.Message("Error", "No Text");
    	end
    end
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  3. #3
    Join Date
    Mar 2007
    Posts
    452

    Grin

    com'on man it doesnt work again ?!
    can it b because it is scripts folder !

    Code:
    new_contents = Input.GetText("Input1");
    if(e_Key==13)then -- Enter is pressed
    	if(new_contents~="")then -- Making sure the new content is nog empty!
    		TextFile.WriteFromString("Autoplay\\Scripts\\history.txt", new_contents.."\r\n", true);
    	else
    		Dialog.Message("Error", "No Text");
    	end
    end

  4. #4
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by GoOgLe View Post
    com'on man it doesnt work again ?!
    can it b because it is scripts folder !

    Code:
    new_contents = Input.GetText("Input1");
    if(e_Key==13)then -- Enter is pressed
    	if(new_contents~="")then -- Making sure the new content is nog empty!
    		TextFile.WriteFromString("Autoplay\\Scripts\\history.txt", new_contents.."\r\n", true);
    	else
    		Dialog.Message("Error", "No Text");
    	end
    end
    Are you sure the object "Input1" exists? Try this example (works fine here)
    Attached Files
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts