Pook Posted October 28, 2008 Share Posted October 28, 2008 Okay, Ive been looking around, and I cant find what Im looking for. So I'm going to suck it up and ask for help. I have a script that connects to a remote computer to run a third party app called Remotely Anywhere. I wanted to add a HISTORY dropdown combo box to the script. So I started playing around with GUICtrlCreateCombo and INI files. The Problem:-I want the script to write the last 100 Hostname I connected to (or type in). The problem is I dont know how to write the information to an INI file the right order. (From recent connection to very last connection)- Also I want it to overwrite the information after I pass the 100 mark. Just keep the most recent 100. Example GUI Layout from my script:#include <GuiConstants.au3> GUICreate("(Beta) Problem (Beta)", 350, 210) $HistoryGroup= GUICtrlCreateGroup("History", 10, 10, 330, 80) $HistoryList = GUICtrlCreateCombo("History List", 30, 30, 290, 21) $ActivateHistory = GUICtrlCreateButton("Connect", 130, 60, 90, 20) $Exit = GUICtrlCreateButton("Exit", 250, 160, 90, 20) GUISetState() ;Read ini $Config = IniReadSection("History.ini", "History")Any ideas? Link to comment Share on other sites More sharing options...
RickJ Posted October 28, 2008 Share Posted October 28, 2008 I'm new here so I may not know what I'm talking about so take what I say with a grain of salt. I saw a couple of user defined functions, _FileReadToArray & _FileWriteFromArray, that may be of use. I would just keep the history in an array and then use these fuction to dump/retrieve it to/from the history file. There is another user defined function _ArrayReverse that may also prove useful. Link to comment Share on other sites More sharing options...
cherdeg Posted October 28, 2008 Share Posted October 28, 2008 Maybe you could e.g. use IniWriteSection() to allocate the entries to one section for each date (add the current date) to the section name. Then you could add the current time to the name of the key containing the value of the last used host. Easier you could just add current date&time to name of the key. So when reading the ini-file you would have to go backwards from the current date&time and read the values in descending order. Link to comment Share on other sites More sharing options...
Pook Posted October 30, 2008 Author Share Posted October 30, 2008 So when reading the ini-file you would have to go backwards from the current date&time and read the values in descending order. I've been looking around and I don't see how I read it in "descending order". So it show up in the 'GUICtrlCreateCombo' that way. MY CODE SO FAR expandcollapse popup#include <GuiConstants.au3> GUICreate("(Beta) (Beta-Test) (Beta)", 350, 210) $grpHistory= GUICtrlCreateGroup("History", 10, 10, 330, 80) $HistoryList = GUICtrlCreateCombo("Choose", 30, 30, 290, 21) $ActivateHistory = GUICtrlCreateButton("Connect", 130, 60, 90, 20) $Exit = GUICtrlCreateButton("Exit", 250, 160, 90, 20) GUISetState() $Config = IniReadSection("History.ini", "History") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $Config[0][0] GUICtrlSetData($HistoryList, $Config[$i][0] & "<>" & $Config[$i][1] ) Next EndIf ;------------------------------------- While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Exit ExitLoop Case $msg = $ActivateHistory $data= GUICtrlRead($HistoryList) $HistoryConfigArray=stringsplit($data,"<>") for $i = 1 to $HistoryConfigArray[0] next $HostNameINI = $HistoryConfigArray[1] $UsernameINI = $HistoryConfigArray[3] $TimeStampINI = $HistoryConfigArray[5] MsgBox(48, "Test", " HostName >> " & $HostNameINI , 0) MsgBox(48, "test", "Username >> " & $UsernameINI , 0) MsgBox(48, "test", "TimeStamp >> " & $TimeStampINI , 0) Case Else ;;; EndSelect WEnd Exit INI FILE *example [History] Workstation1=JOEBLOW1<>10/29/2008 23:03:34 Workstaiton2=JOEBLOW2<>10/29/2008 23:03:32 screenshot of gui Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now