Jump to content

Iniwrite question


Go to solution Solved by Melba23,

Recommended Posts

Hello,

First things first.

I'm making a little program for work so i can keep track of the problems people report to me or when someone lends a specific item.

 

However i encountered a problem(well problem i'm just a newb). The thing i want to do is that i can report multiple subjects to an accdom id(accdom id is the username) so i can look it up and not just 1 subject a person like it works now.(see .ini file to see what i am going for)

[User 1]
Subject=Problem 1
Uitgaven=4
Teruggaven=4

[User 1]
Subject=Problem 2
Uitgaven=1
Teruggaven=4

Altho i don't know if there is a better way to do this. 

The code i have so far is:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $IAccdomID, $sSubject, $ISubject, $sAccdomID, $CBUit, $sBUit, $CBTerug, $sBTerug

Opt("GUIOnEventMode", 1)

Menu()
Func Menu()
$GMenu = GUICreate("Menu", 221, 251, 222, 691)
$BNew = GUICtrlCreateButton("New", 50, 5, 121, 41)
GUICtrlSetOnEvent($BNew, "new")
$BSearch = GUICtrlCreateButton("Search", 50, 50, 121, 41)
GUICtrlSetOnEvent($BSearch, "search")
$BExit = GUICtrlCreateButton("Exit", 50, 195, 121, 51)
GUICtrlSetOnEvent($BExit, "Close")
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
EndFunc

Func new()
$GNew = GUICreate("New", 613, 438, 714, 253)
$IAccdomID = GUICtrlCreateInput("Accdom ID", 5, 5, 171, 21)
$ISubject = GUICtrlCreateInput("Subject", 5, 35, 171, 21)
$ENew = GUICtrlCreateEdit("", 0, 65, 611, 371)
$BSend = GUICtrlCreateButton("Send", 520, 20, 76, 31)
GUICtrlSetOnEvent($BSend, "SendNew")
$CBUit = GUICtrlCreateCheckbox("Uitgaven", 310, 5, 85, 21)
$CBTerug = GUICtrlCreateCheckbox("Teruggaven", 310, 35, 85, 21)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "closenew")
EndFunc

Func  SendNew()
$sSubject = GUICtrlRead($ISubject)
$sAccdomID = GUICtrlRead($IAccdomID)
$sBUit = GUICtrlRead($CBUit)
$sBTerug = GUICtrlRead($CBTerug)
IniWrite(@ScriptDir & "\data.ini", $sAccdomID, "Subject", $sSubject)
IniWrite(@ScriptDir & "\data.ini", $sAccdomID, "Uitgaven", $sBUit)
IniWrite(@ScriptDir & "\data.ini", $sAccdomID, "Teruggaven", $sBTerug)
EndFunc

Func search()

EndFunc

Func Close()
   Exit
EndFunc

Func closenew()
   GUISetState(@SW_HIDE)
EndFunc

While 1
    Sleep(50)
WEnd

I hope this is thread is clear and that someone is able to help me.

 

Greetings and have a nice day ^^

Link to comment
Share on other sites

  • Moderators

If you want to be able to link multiple "tickets" to a single person, the easiest thing to do is a small db. I would highly suggest looking into the _SQLite_ functions in the help file.

 

Edit: Or, don't reinvent the wheel and download one of the many open source ticketing systems, such as Request Tracker, OTRS, Triage, etc.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

sir anyone can help me to fix my program please i am new here i dont know much about it i made all the program but just 1-2 bugs in this pls help me to fix it 

by coming on team viewer 

thanks in advance

Not how it works here.

Create a new topic and ask your question.

Stop hijacking other members threads.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

satanttin,

I would change the ini entries to have all the info on a single line - like this:

[User 1]
Subject 1=A problem|4|1
Subject 2=Another problem|4|1
Subject 3=And another problem|1|1
Subject 4=And here is No 4|4|4
[User 2]
Subject 1=Problem|4|4
You can get this working by changing the SendNew function as follows:

Func SendNew()
    $sSubject = GUICtrlRead($ISubject)
    $sAccdomID = GUICtrlRead($IAccdomID)
    $sBUit = GUICtrlRead($CBUit)
    $sBTerug = GUICtrlRead($CBTerug)
    ; Set initial entry value
    $iNewEntry = 0
    ; Now read exisiting entries
    $aListing = IniReadSection(@ScriptDir & "\data.ini", $sAccdomID)
    If Not @error Then
        ; Sort to get in order
        _ArraySort($aListing)
        ; Now extract the index of the last entry
        $iNewEntry = StringReplace($aListing[$aListing[0][0]][0], "Subject ", "")
    EndIf
    ; Increase for the next entry
    $iNewEntry += 1
    ; Now write all data for this entry as a new line in the ini - you can easily separate the Uit/Terug values when needed
    IniWrite(@ScriptDir & "\data.ini", $sAccdomID, "Subject " & $iNewEntry, $sSubject & "|" & $sBUit & "|" & $sBTerug)
    GUIDelete($GNew)
EndFunc   ;==>SendNew
You will also need to make $GNew Global in scope, and include the Array library. ;)

Please ask if you have any questions. :)

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

The INI file format and accompanying conventions are not a suitable container for this use case. I second Jlogan3o13 on switching to custom SQLite or to select a full-fledged ticket-processing software.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

satanttin,

I would change the ini entries to have all the info on a single line - like this:

[User 1]
Subject 1=A problem|4|1
Subject 2=Another problem|4|1
Subject 3=And another problem|1|1
Subject 4=And here is No 4|4|4
[User 2]
Subject 1=Problem|4|4
You can get this working by changing the SendNew function as follows:

Func SendNew()
    $sSubject = GUICtrlRead($ISubject)
    $sAccdomID = GUICtrlRead($IAccdomID)
    $sBUit = GUICtrlRead($CBUit)
    $sBTerug = GUICtrlRead($CBTerug)
    ; Set initial entry value
    $iNewEntry = 0
    ; Now read exisiting entries
    $aListing = IniReadSection(@ScriptDir & "\data.ini", $sAccdomID)
    If Not @error Then
        ; Sort to get in order
        _ArraySort($aListing)
        ; Now extract the index of the last entry
        $iNewEntry = StringReplace($aListing[$aListing[0][0]][0], "Subject ", "")
    EndIf
    ; Increase for the next entry
    $iNewEntry += 1
    ; Now write all data for this entry as a new line in the ini - you can easily separate the Uit/Terug values when needed
    IniWrite(@ScriptDir & "\data.ini", $sAccdomID, "Subject " & $iNewEntry, $sSubject & "|" & $sBUit & "|" & $sBTerug)
    GUIDelete($GNew)
EndFunc   ;==>SendNew
You will also need to make $GNew Global in scope, and include the Array library. ;)

Please ask if you have any questions. :)

M23

 

Thanks for your reply, i'm kinda busy with work atm but i will test this asp and let u know if it works^^ (looks easier than the first reply that made my head hurt xD)

Link to comment
Share on other sites

  • Moderators

vikasgoyals, first we don't appreciate hijacking of someone else's thread. If you have a question: create your own post, explain in detail what you're trying to do, be prepared to show what you have tried on your own. As J1 is trying to explain, this is not a forum where you put in a request and someone else does the work for you. We're happy to help you learn, but you need to be willing to do so.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

@OP, for the SQLite route, you might try something like this, just to give you an idea of what it would look like:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()
$hMyDB = _SQLite_Open(@DesktopDir & "\my.db")

    _SQLite_Exec($hMyDB, "CREATE TABLE Incidents (Name, Phone Number, Ticket Number, Problem);")
    _SQLite_Exec($hMyDB, "INSERT INTO Incidents VALUES ('Bill Jones','517.222.5555', 'SRC_108907', 'User locked out of network');")
    _SQLite_Exec($hMyDB, "INSERT INTO Incidents VALUES ('Tammy Coleman','517.222.5554', 'SRC_108910', 'User cannot print from Excel');")
    _SQLite_Exec($hMyDB, "INSERT INTO Incidents VALUES ('Bill Jones','517.222.5555', 'SRC_108912', 'User locked out of network - AGAIN');")
    _SQLite_Exec($hMyDB, "INSERT INTO Incidents VALUES ('Bill Jones','517.222.5555', 'SRC_108914', 'User fired');")

$iRval = _SQLite_GetTable2d(-1, "SELECT * FROM Incidents;", $aResult, $iRows, $iColumns)
    If $iRval = $SQLITE_OK Then
        GUICreate("Show my SQLite Data", 500, 300)
        $sListView = GUICtrlCreateListView("Name|Phone Number|Ticket Number|Problem", 10, 10, 480, 280)
            For $i = 1 To UBound($aResult) - 1
                GUICtrlCreateListViewItem($aResult[$i][0] & "|" & $aResult[$i][1] & "|" & $aResult[$i][2] & "|" & $aResult[$i][3], $sListView)
            Next


        GUISetState(@SW_SHOW)

            While 1
                Switch GUIGetMsg()
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                EndSwitch
            WEnd

        GUIDelete()

    Else
        MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg())
    EndIf

_SQLite_Close()
_SQLite_Shutdown()

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

satanttin,

An afterthought was that you may need to use StringFormat to pad the number with leading 0's so the sorting works properly- let me know if you need a hand with that. :)

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

@JLogan3o13

Thanks i have no clue on how to implent this inside my onevent script but thanks for replaying anyways ^^

@Melba23

i've tried puting your Function in my script but it gives me an error when i try to enter a second entry to a user with just the first entry it works:

"C:\Users\tti007\Desktop\testy.au3" (46) : ==> Unknown function name.:
_ArraySort($aListing)

And tbh i can use a little help with StringFormat since i have no clue on what to do with that :$ 

Link to comment
Share on other sites

  • Moderators
  • Solution

satanttin,

Did you include the Array library as I mentioned in my post? :huh:

Put

#include <Array.au3>
at the top of your script and all should be well. ;)

I will look into how we might use StringFormat this afternoon. :)

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

satanttin,

Did you include the Array library as I mentioned in my post? :huh:

Put

#include <Array.au3>
at the top of your script and all should be well. ;)

I will look into how we might use StringFormat this afternoon. :)

M23

 

omg guess i missed that haha. but it works now so thank you sir ^^

Link to comment
Share on other sites

  • Moderators

satanttin,

It was trivial so I did it immediately: :)

Func SendNew()
    $sSubject = GUICtrlRead($ISubject)
    $sAccdomID = GUICtrlRead($IAccdomID)
    $sBUit = GUICtrlRead($CBUit)
    $sBTerug = GUICtrlRead($CBTerug)
    ; Set initial entry value
    $iNewEntry = 0
    ; Now read exisiting entries
    $aListing = IniReadSection(@ScriptDir & "\data.ini", $sAccdomID)
    If Not @error Then
        ; Sort to get in order
        _ArraySort($aListing)
        ; Now extract the index of the last entry - use Number to strip the leading 0's
        $iNewEntry = Number(StringReplace($aListing[$aListing[0][0]][0], "Subject ", ""))
    EndIf
    ; Increase for the next entry
    $iNewEntry += 1
    ; Now write all data for this entry as a new line in the ini - you can easily separate the Uit/Terug values when needed
    ; Note StringFormat used to pad the number with leading 0's so the sort will work properly
    IniWrite(@ScriptDir & "\data.ini", $sAccdomID, "Subject " & StringFormat("%05s", $iNewEntry), $sSubject & "|" & $sBUit & "|" & $sBTerug)
    GUIDelete($GNew)
EndFunc   ;==>SendNew
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

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