Jump to content

help me thank


toxicvn
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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

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

 

Link to comment
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 !!!!

Link to comment
Share on other sites

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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...