Jump to content

Need Array help


Recommended Posts

Hey there, I am working on a "note" app which sync via sftp. I am trying to display all contents of a folder in a tree view (and then I want to select one of the note.txt files in this folder and edit it).

Anyway, I am currently stuck at displaying the folder content:

#cs ----------------------------------------------------------------------------
 
 AutoIt Version: 3.3.8.1
 Author:         
 
 Script Function:
Sync all notes.txt within a folder via sftp
 
#ce ----------------------------------------------------------------------------
 
; Script Start - Add your code below here
 
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <SFTPEx.au3>
#include <Array.au3>
$MainGUI = GUICreate("MyNotes", 984, 841, 259, 141)
$Edit1 = GUICtrlCreateEdit("", 208, 72, 755, 729)
GUICtrlSetData(-1, "Edit1")
$TreeView = GUICtrlCreateTreeView(16, 72, 177, 729, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$ServerGroup = GUICtrlCreateGroup("Server", 16, 8, 195, 49)
$ServerInput = GUICtrlCreateInput("ftp.com", 24, 24, 129, 21)
$PortInput = GUICtrlCreateInput("1337", 160, 24, 45, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$UserGroup = GUICtrlCreateGroup("User", 218, 8, 145, 49)
$UserInput = GUICtrlCreateInput("User", 226, 24, 129, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$PasswordGroup = GUICtrlCreateGroup("Password", 370, 8, 145, 49)
$PasswordInput = GUICtrlCreateInput("Password", 378, 24, 129, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Status", 522, 8, 145, 49)
$Status = GUICtrlCreateLabel("Disconnected", 524, 31, 140, 17, $SS_CENTER)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ConnectButton = GUICtrlCreateButton("Connect", 682, 16, 137, 41)
$SavesyncButton = GUICtrlCreateButton("Save / Sync", 826, 16, 137, 41)
$mFile_Menu = GUICtrlCreateMenu("File")
$mSettings_Item = GUICtrlCreateMenuItem("Einstellungen", $mFile_Menu)
$mCheckUp_Item = GUICtrlCreateMenuItem("Update", $mFile_Menu)
GUICtrlCreateMenuItem("", $mFile_Menu)
$mExit_Item = GUICtrlCreateMenuItem("Exit", $mFile_Menu)
 
$mHelp_Menu = GUICtrlCreateMenu("?")
$mAbout_Item = GUICtrlCreateMenuItem("About", $mHelp_Menu)
GUISetState(@SW_SHOW)
 
 
While 1
 
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE 
            Exit 
        Case $mExit_Item 
            Exit 
Case $ConnectButton
$sPath = 'psftp.exe'
$hSession = _SFTP_Open($sPath)
$sUsername = GUICtrlRead($UserInput)
$sPassword = GUICtrlRead($PasswordInput)
$sServerName = GUICtrlRead($ServerInput)
$iServerPort = GUICtrlRead($PortInput)
$hConnection = _SFTP_Connect ( $hSession, $sServerName , $sUsername , $sPassword , $iServerPort  )
sleep(2000)
Local $Array[10]
_SFTP_ListToArray( $hConnection  )
sleep(2000)
_ArrayDisplay($Array)
EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

aphesia,

Look at my ChooseFileFolder UDF (the link is in my sig) - it will do this for you. :)

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

Yes, and the code should be enclosed within code tags, and not plain text tags. :P

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

 

As _SFTP_ListToArray() returns an array, you should write

$Array = _SFTP_ListToArray($hConnection)
_ArrayDisplay($Array)

 

Thanks you , your UDF is really nice BUT:

How to I tell your udf to use the sftp-folder as $sRoot ?

Link to comment
Share on other sites

Not sure you need a treeview

You can get your notes names list with _SFTP_ListToArray from the concerned remote folder and put the array into a list or listview, then select one note,  use _SFTP_FileGet to get the .txt to a temp file and then edit it

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...