toxicvn Posted February 28, 2009 Share Posted February 28, 2009 i have this code : expandcollapse popup#Include <Array.au3> #Include <File.au3> $DATA = FileOpenDialog("Lua chon file chua ", "", "Text (*.txt)", 1) if $DATA = "" Then MsgBox(0,"","ban phai chon file chua ") $DATA = FileOpenDialog("Lua chon file chua ", "", "Text (*.txt)", 1) ;... Else xuli() EndIf Func xuli() $FILEDATA = FileOpen($DATA, 0) ;$FILELINE = FileRead($FILEDATA) ;$array = StringSplit($FILELINE," | ",1) $dauphancach = "|" ;_ArrayDisplay($array,"day ne") $sodong = _FILECOUNTLINES($DATA) MsgBox(0,"month year exp ",$sodong) For $i = 1 to $sodong $line = FileReadLine($FILEDATA) $array = StringSplit($line,$dauphancach,1) If $line = "" Then MsgBox(0,"month year exp ","bom ghe mong") Else MsgBox(0,"month year exp ",$array[2] & @TAB & $array[3]) ;If @error = -1 Then ExitLoop EndIf Next EndFunc i want when i is press cancel button on then "$DATA = FileOpenDialog("Lua chon file chua ", "", "Text (*.txt)", 1)" then Disable function xuli() i dont want use exit() becase when i add that code to gui then my gui will exit help me thank sorry because my english not well Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 28, 2009 Moderators Share Posted February 28, 2009 toxicvn,Use a While...WEnd loop to keep getting back to the file dialog. That way you do not need a function at all!#include <File.au3> $DATA = "" While $DATA = "" MsgBox(0,"","ban phai chon file chua ") $DATA = FileOpenDialog("Lua chon file chua ", "", "Text (*.txt)", 1) WEnd $FILEDATA = FileOpen($DATA, 0) ;$FILELINE = FileRead($FILEDATA) ;$array = StringSplit($FILELINE," | ",1) $dauphancach = "|" ;_ArrayDisplay($array,"day ne") $sodong = _FILECOUNTLINES($DATA) MsgBox(0,"month year exp ",$sodong) For $i = 1 to $sodong $line = FileReadLine($FILEDATA) $array = StringSplit($line,$dauphancach,1) If $line = "" Then MsgBox(0,"month year exp ","bom ghe mong") Else MsgBox(0,"month year exp ",$array[2] & @TAB & $array[3]) ;If @error = -1 Then ExitLoop EndIf NextYou need to think about what to do if the user decides to exit the program without selecting a file. Perhaps make a count of the number of times you go round the While...WEnd loop and then exit after 3 cancels.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
toxicvn Posted March 2, 2009 Author Share Posted March 2, 2009 You need to think about what to do if the user decides to exit the program without selecting a file. Perhaps make a count of the number of times you go round the While...WEnd loop and then exit after 3 cancels.How to write that code ?help methank thank !!!! Link to comment Share on other sites More sharing options...
CodyBarrett Posted March 2, 2009 Share Posted March 2, 2009 about 70% of autoit users WILLNOT write you a script for you. including me [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
toxicvn Posted March 3, 2009 Author Share Posted March 3, 2009 about 70% of autoit users WILLNOT write you a script for you. including meyou are very curti ask because i am a new !because a forum is share and discuss all we dont understand ! Link to comment Share on other sites More sharing options...
CodyBarrett Posted March 3, 2009 Share Posted March 3, 2009 you are very curt i ask because i am a new ! because a forum is share and discuss all we dont understand !i realize this... BUT from the look of it, 50 or so posts from you... you not 'NEW' not completely atleast, Autoit is A VERY powerfull language, and its easy to understand, once you overcome the basics, so if you have enough practice youll nearly be able to do any project you want.. and to your earier post... what you could try melba's idea, also i recommend using WHILE 1 WEND is EVERYSINGLE script, even if the code in it is NOT used like this While1 sleep (100) wend just to save RAM, and the func should be disabled once ONE time through or unless specified through a loop. [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
toxicvn Posted March 3, 2009 Author Share Posted March 3, 2009 thank for help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now