Sign in to follow this  
Followers 0
toxicvn

help me thank

7 posts in this topic

i have this code :

#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

Share this post


Link to post
Share on other sites



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
    
Next

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.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

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 me

thank thank !!!!

Share this post


Link to post
Share on other sites

about 70% of autoit users WILLNOT write you a script for you. including me

Share this post


Link to post
Share on other sites

about 70% of autoit users WILLNOT write you a script for you. including me

you are very curt

i ask because i am a new !

because a forum is share and discuss all we dont understand !

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

thank for help

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  
Followers 0