Sign in to follow this  
Followers 0
jacq

SOLVED:Path from function to input out side function

6 posts in this topic

#1 ·  Posted (edited)

Welcome

How I can display path from function out side function in input?

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
 
 
$Parent1 = GUICreate("Program", 550, 260, -1, -1)
 
 
$file2 = GUICtrlCreateInput("", 20, 20, 300, 20)
 
GUISetOnEvent($GUI_EVENT_CLOSE, "Events")
 
 
$plik = GUICtrlCreateButton ("Dodaj plik", 20, 20, 100, 30)
GUICtrlSetOnEvent(-1, "PlikPressed")
 
GUISetOnEvent($GUI_EVENT_CLOSE, "Events")
 
GUISetState(@SW_SHOW)
 
; Just idle around
While 1
Sleep(10)
Wend
 
Func verPressed()
Run("winver")
EndFunc
 
; Just idle around
While 1
Sleep(10)
Wend
 
; END
 
 
 
Func PlikPressed()
 
$message = "Wybierz plik .exe programu"
 
$var = FileOpenDialog($message, @WindowsDir & "\", "Plik (*.exe)", 1)
 
If @error Then
    MsgBox(4096, "", "Plik .exe nie został wskazany")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096, "", "Wybrałeś plik " & $var)
EndIf
   
EndFunc
 
 
 
Func Events()
 
Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
Exit
 
Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
 
Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
 
EndSelect
 
EndFunc
Edited by jacq

Share this post


Link to post
Share on other sites



You could declare the path outside the function, and then call your function as follows:

Func PlikPressed($var)

You could also set the variable to Global, but doing so within the function is not best practice.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

jacq,

I presume you mean the result of the FileOpenDialog - if so then something like this would work: :)

$var = StringReplace($var, "|", @CRLF)
MsgBox(4096, "", "Wybrales plik " & $var)
GUICtrlSetData($file2, $var)

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

Thanks Melba23 this is working but when I want read from $file2 and display this is not showing me the path is showing me numer 7 and I don't now why.

MsgBox(4096, "hhhhh", $file2)

Share this post


Link to post
Share on other sites

Sorry I forgot about GUICtrlRead($file2).

Thank you very much

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