PDA

View Full Version : text file help


mustafa06
01-19-2008, 08:48 AM
help me please

For example :

my desktop have mustafa.txt ( and ı open mustafa.txt ı saw for example bla bla bla )

-- Code
UserText = Input.GetText("UserText");
SaveTo = Dialog.FileBrowse(false, "Save to:", _DesktopFolder, "Text files (*.txt)|*.txt|", "", "txt", false, false);

DoesExist = File.DoesExist(SaveTo[1]);
if DoesExist then
Replace = Dialog.Message("Warning", "File " .. SaveTo[1] .. " already exist. Do you want to replace the file?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if Replace == IDYES then
TextFile.WriteFromString(SaveTo[1], UserText, false);
else
Dialog.Message("Warning", "File not saved.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
TextFile.WriteFromString(SaveTo[1], UserText, false);
end

-- End

Result :

ım write input (input name = UserText ) " mustafa " and then save to mustafa.txt on desktop but ı click open mustafa.txt ı saw mustafa where bla bla bla ? ı want if ı save mustafa.txt bla bla and ı saw mustafa.


I cant speak english very well , ty :yes

RizlaUK
01-19-2008, 09:14 AM
Hi,

Try it like this (note the bits in red)
UserText = Input.GetText("UserText");
SaveTo = Dialog.FileBrowse(false, "Save to:", _DesktopFolder, "Text files (*.txt)|*.txt|", "", "txt", false, false);

DoesExist = File.DoesExist(SaveTo[1]);
if DoesExist then
Replace = Dialog.Message("Warning", "File " .. SaveTo[1] .. " already exist. Do you want to replace the file?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if Replace == IDYES then
OldText=TextFile.ReadToString(SaveTo[1]);
TextFile.WriteFromString(SaveTo[1], OldText.."\r\n"..UserText, false);
else
Dialog.Message("Warning", "File not saved.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
TextFile.WriteFromString(SaveTo[1], UserText, false);
end

Hope it helps :yes

mustafa06
01-19-2008, 09:16 AM
Hi,

Try it like this (note the bits in red)
UserText = Input.GetText("UserText");
SaveTo = Dialog.FileBrowse(false, "Save to:", _DesktopFolder, "Text files (*.txt)|*.txt|", "", "txt", false, false);

DoesExist = File.DoesExist(SaveTo[1]);
if DoesExist then
Replace = Dialog.Message("Warning", "File " .. SaveTo[1] .. " already exist. Do you want to replace the file?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if Replace == IDYES then
OldText=TextFile.ReadToString(SaveTo[1]);
TextFile.WriteFromString(SaveTo[1], OldText.."\r\n"..UserText, false);
else
Dialog.Message("Warning", "File not saved.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
TextFile.WriteFromString(SaveTo[1], UserText, false);
end

Hope it helps :yes

ty too ty too :yes:yes:yes

Samio
01-19-2008, 09:42 AM
Hello.How Are ...

UserText = Input.GetText("UserText");
SaveTo = Dialog.FileBrowse(false, "Save to:", _DesktopFolder, "Text files (*.txt)|*.txt|", "", "txt", false, false);

DoesExist = File.DoesExist(SaveTo[1]);
if DoesExist then
Replace = Dialog.Message("Warning", "File " .. SaveTo[1] .. " already exist. Do you want to replace the file?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if Replace == IDYES then
TextFile.WriteFromString(SaveTo[1], "\r\n"..UserText, true);
else
Dialog.Message("Warning", "File not saved.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
TextFile.WriteFromString(SaveTo[1], "\r\n"..UserText, true);
end

RizlaUK
01-19-2008, 09:45 AM
lol, why dident i think of that.......been working with another program for to long...im slipping

mustafa06
01-19-2008, 02:08 PM
Code :
UserText = Input.GetText("UserText");
SaveTo = Dialog.FileBrowse(false, "Save to:", _DesktopFolder, "Text files (*.txt)|*.txt|", "", "txt", false, false);

DoesExist = File.DoesExist(SaveTo[1]);
if DoesExist then
Replace = Dialog.Message("Warning", "File " .. SaveTo[1] .. " already exist. Do you want to replace the file?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if Replace == IDYES then
TextFile.WriteFromString(SaveTo[1], "\r\n"..UserText, true);
else
Dialog.Message("Warning", "File not saved.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
TextFile.WriteFromString(SaveTo[1], "\r\n"..UserText, true);
end
End

for example ; ım write input ( Usertext ) "12345" if ı save text file ı want to saw name "12345 --- How ? :rolleyes

RizlaUK
01-19-2008, 03:25 PM
try this way:

UserText = Input.GetText("UserText");
SaveTo = Dialog.FileBrowse(false, "Save to:", _DesktopFolder, "Text files (*.txt)|*.txt|", "", "txt", false, false);

DoesExist = File.DoesExist(SaveTo[1]);
if DoesExist then
Replace = Dialog.Message("Warning", "File " .. SaveTo[1] .. " already exist. Do you want to replace the file?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if Replace == IDYES then
OldText=TextFile.ReadToString(SaveTo[1]);
TextFile.WriteFromString(SaveTo[1], UserText.." - "..OldText, false);
else
Dialog.Message("Warning", "File not saved.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
TextFile.WriteFromString(SaveTo[1], UserText, false);
end

if that is not what you need then you are going to have to be a little clearer about what you want

when you say name, do you mean the file name ?