Sign in to follow this  
Followers 0
Srex

Outputlocation bugs

25 posts in this topic

hi forum i have this code, which will make the user select an output location.

Case $ButtonBrowseOutputLoc
            $sFileSelectFolder = FileSelectFolder("Select output location", "")
            ElseIf Not @error Then

                $OutPutLoc = $sFileSelectFolder & '\settings.ini'
                GUICtrlSetData($InputCheatDir, $OutPutLoc)
            EndIf

It works great and all BUT if they select the root of a drive (for example 'c') Then it says

"C:settings.ini" instead of "C:settings.ini"

i tried putting up a condition that if $sFileSelectfolder (this variable doesnt include the root part theres a seperate function for that) is empty then "settings.ini" else "/settings.ini" but it doesnt work for me :( any suggestions?

Also with this im having a bug, so if the user doesnt filll out the output location it just disapears upon creation. instead of defaulting to the @scriptdir .. i either need to:

1: force the user to select (not prefered)

2: make it default at @scriptdir

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If Not @error Then
    If $sFileSelectFolder="C:\" Then
        ConsoleWrite("c has been selected"&@crlf)
    $OutPutLoc = $sFileSelectFolder & 'settings.ini'
    Else
    $OutPutLoc = $sFileSelectFolder & '\settings.ini'
    EndIf
    ConsoleWrite($OutPutLoc)

For your "bug" on a default location just do this at the top somewere ....

$sFileSelectFolder=@scriptdir

That way if they never push the button or cancel it will still be set to the @scriptdir.  If they do choose a different location the default will get overridden.

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
If Not @error Then
    If $sFileSelectFolder="C:\" Then
        ConsoleWrite("c has been selected"&@crlf)
    $OutPutLoc = $sFileSelectFolder & 'settings.ini'
    Else
    $OutPutLoc = $sFileSelectFolder & '\settings.ini'
    EndIf
    ConsoleWrite($OutPutLoc)

For your "bug" on a default location just do this at the top somewere ....

$sFileSelectFolder=@scriptdir

That way if they never push the button or cancel it will still be set to the @scriptdir.  If they do choose a different location the default will get overridden.

If I chose that I'd need to set a case because they can choose every drive from a-z and store the settings.ini in a variable instead hmm

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@JohnOne always has a more elegant solution :>

@Srex I am not sure what you mean with your last comment.  Are you talking about the default directory?

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

@JohnOne always has a more elegant solution :>

@Srex I am not sure what you mean with your last comment.  Are you talking about the default directory?

 

of OP?

Yes I mean if the user does not select an output location for the settings file then it will be put at @scriptdir

otherwise it should be put where the user tells it to

Share this post


Link to post
Share on other sites

@Srex, no, I meant I don't follow this:

 

If I chose that I'd need to set a case because they can choose every drive from a-z and store the settings.ini in a variable instead hmm


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@Srex, no, I meant I don't follow this:

ohh excuse me.

because this

If $sFileSelectFolder="C:\" Then

only returns true if they select the root of the c drive

i have no clue what letter their drive is :)

so i need to make one for every letter

can i have cases within cases? like:

case $ButtonBrowseOutpuLoc
        case $sFileSelectFolder="C:\"
                 $OutPutLoc = $sFileSelectFolder & 'settings.ini'
        case $sFileSelectFolder="D:\"
                 $OutPutLoc = $sFileSelectFolder & 'settings.ini'

 etc etc so case button gets pressed, run these cases

Edited by Srex

Share this post


Link to post
Share on other sites

 

There is also the Ternary way.

$fol = FileSelectFolder("Select output location", "")

$fol = (StringRight($fol, 1) = "\") ? StringTrimRight($fol, 1) : $fol

$fol &= "\folder\file.ext"

ConsoleWrite($fol & @LF)

okay I need to try and understand what this actually does :P

But it looks very good and efficient sir

Share this post


Link to post
Share on other sites

Srex,

You do realise that Windows is quite happy to accept "" in place of "" and so it does not matter whether there is an additional "" in the path? :huh:

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

Srex,

You do realise that Windows is quite happy to accept "" in place of "" and so it does not matter whether there is an additional "" in the path? :huh:

M23

Really?

Are you kidding me :D

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

They are both exactly the same really, ? : just replaces if then.

If the rightmost character is then that will trimmed off, else it stays the same.

 

aaah i see thanks dude

yeah but theres a read only input box, so I would like it to look correct for the user, so he/she doesn't think it will bug :)

As for the case being almost the same I heard from a coder friend that case is far more efficient :) And I prefer to learn it the best way in the beginning so i don't have to go back and reschool myself :P

Edited by Srex

Share this post


Link to post
Share on other sites

Srex,

 

I would like it to look correct for the user

if you are manipulating the path in some way like splitting it at ,

Just run StringReplace($sPath, "", "") on the path before using it. ;)

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

#20 ·  Posted (edited)

Srex,

 

Just run StringReplace($sPath, "", "") on the path before using it. ;)

M23

yeah this is perfect

Case $ButtonBrowseOutputLoc
            $sFileSelectFolder = FileSelectFolder("Select output location", "")
                If Not @error Then

                $OutPutLoc = $InputWinLocation & $sFileSelectFolder & '\settings.ini'
                StringReplace($OutPutLoc, "\\", "\")
                GUICtrlSetData($InputChDir, $OutPutLoc)
            EndIf

But then it still does + i writes "43" infront of the windows location

$InputWinLocation is btw the user input for the root of the drive

'>

Edited by Srex

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