Jump to content
Sign in to follow this  
retaly

Small problem with FileWrite

Recommended Posts

hy guys,

(first i'd like to say i'm sorry for my last topic before this, i have been never red rules before this time, i'm sorry again, and ty for everything.)

i'm using filewrite for save in my script, $save is one edit box what will going into something.ini file.

FileWrite("something.ini", GUICtrlRead($save))

how can i do that: if something.ini file already exist, it cant rewrite the old something.ini and i get some message, for example msgbox,

i'm almost ready with my first script what is rly interesting for me, but this thing still missing from script :S

Share this post


Link to post
Share on other sites

retaly,

i'm sorry for my last topic before this, i have been never red rules before this time

Well, I hope you have read them now. :D

As to writing an ini file - I suugest you take a look at the Ini* functions in the Help file. They make it really easy to save/read settings, etc in a file without worrying about FielRead/Write. ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

yes ofc i read.

now i changed the file here in forum, in fact its one .dat file, and one dat file = one option for script, and i should to fix it, important thing how script not rewrite/change .dat file if its already exist "settings.dat, save.dat etc" if i wanna to save it again by my mistake it will give me a notice about file," its already exist and not possible to rewrite".

part of my scrip,

for example like this:

_FileCreate("cfgname.dat")
FileWrite("cfgname.dat", GUICtrlRead($cfg_options))

$server = 'ftp.myhost.com
$username = 'mydomain'
$pass = 'mypassword'

$Open = _FTPOpen('minisha')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, @ScriptDir & "cfgname.dat", '/cfg/' & GUICtrlRead($give_name) &'.dat', 0x08000000)
$Ftpc = _FTPClose($Open)

nah this script do this:

write one file in script dir: cfgname.dat,

then write the options into it ($cfg_options)

then connecting to my ftp and upload this file: cfgname.dat as i named($give_name)

i hope do u understand me, i'm sorry for my bad english, i'm trying to explain for you what is my problem. :S

Edited by retaly

Share this post


Link to post
Share on other sites

retaly,

If all you want is to prevent overwriting a file, then use FilExists to see if it exists before writing ther new file. :)

M23

P.S. There is no need to create the file before using FileWrite, Autoit creates it for you automatically. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

hy dear, i tryed out a lot of thing with fileexist, but i cant do it :S

$server = 'ftp.myhost.com
$username = 'mydomain'
$pass = 'mypassword'

$Open = _FTPOpen('myhost')
$Conn = _FTPConnect($Open, $server, $username, $pass)


$ftp_dir = '/cfg/'
check() 

$Ftpp = _FtpPutFile($Conn, @ScriptDir & "cfgname.dat", $ftp_dir & GUICtrlRead($give_name) &'.dat', 0x08000000)
$Ftpc = _FTPClose($Open)

Func check()
If FileExists($ftp_dir & GUICtrlRead($give_name)) Then

MsgBox(4096, $give_name, "its exist!")
Else
MsgBox(4096, $give_name, "it isn't exist!")
EndIf
EndFunc
Edited by retaly

Share this post


Link to post
Share on other sites

triying to find out whats need to do since i posted here first, i have made a lot of idea here, but still nothing works :S

please let me know how to do it.

for example

:

Func check()
If FileExists($Conn & $ftp_dir & GUICtrlRead($give_name)) &'.dat' = GUICtrlRead($give_name) &'.dat' Then

MsgBox(0, $give_name, "its exist")
Else
MsgBox(0, $give_name, "it isn't exist")
EndIf
EndFunc

Share this post


Link to post
Share on other sites

hm how can i do it with fileexist? because fileread works well if the saved datas same as both example.dat file but if there is a bit differents in between two example.dat file it rewrite the older example.dat, but as i said, if datas same as both example.dat file it dont rewrite, giving msgbox..

and, if i make an ftp uploader, it works fine with normal characters: aaeou etc.. with: éáőöüóúű it doesnt work well, when uploading éá named file it looks :+!"!"+%"/.dat in ftp, but on my pc its éá.dat, with ea format it works when upload to ftp..

i hope u re understand me :S

Func check()
If FileRead(@ScriptDir & '' & GUICtrlRead($give_name) & '.dat') = InetRead("http://users.atw.hu/mydomain/" & $ftp_dir & GUICtrlRead($give_name) & ".dat", 1) Then
;FileExist ???????????????? :S or need another code for FileExist, maybe InetRead doesnt working for it... please help :( this is my last problem
MsgBox(0, $give_name, "Its already exist")
Else
MsgBox(0, $give_name, "It isn't exist")
EndIf
Edited by retaly

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...