Sign in to follow this  
Followers 0
pezo89

require help with making a calculation

22 posts in this topic

#1 ·  Posted (edited)

Hi guys, im looking for a way to retrive some information from a preset ini.file in the same folder.

what im planing on doing is using code #1, to check and uncheck various checkboxes.

when checked it will add the number corresponding to the ini value in the output 1 or 2 box,

so say i check box 1 & 2, and both had an value of 5, it will show 10 in the output1 window

and if i uncheck one box it will take that information away again?

i just need a push in the right direction :huh2:

Codes i have made so far.

#1-UI

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\andreas\documents\_2.kxf
$_2 = GUICreate("Test Kalkulator", 516, 384, 352, 159)
GUISetFont(9, 400, 0, "MS Sans Serif")
GUISetBkColor(0xFFFBF0)
$tab = GUICtrlCreateTab(10, 18, 376, 324, $TCS_HOTTRACK)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tab0 = GUICtrlCreateTabItem("FIBER")
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 88, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 24, 120, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 24, 152, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 24, 184, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
;;;;
;;;NEW Section IPTV
;;;;
$tab1 = GUICtrlCreateTabItem("IPTV")
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 32, 64, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox6 = GUICtrlCreateCheckbox("Checkbox6", 32, 96, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox7 = GUICtrlCreateCheckbox("Checkbox7", 32, 128, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox8 = GUICtrlCreateCheckbox("Checkbox8", 32, 160, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox9 = GUICtrlCreateCheckbox("Checkbox9", 32, 192, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox10 = GUICtrlCreateCheckbox("Checkbox10", 32, 224, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox11 = GUICtrlCreateCheckbox("Checkbox11", 208, 64, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox12 = GUICtrlCreateCheckbox("Checkbox12", 208, 96, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox13 = GUICtrlCreateCheckbox("Checkbox13", 208, 128, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox14 = GUICtrlCreateCheckbox("Checkbox14", 208, 160, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox15 = GUICtrlCreateCheckbox("Checkbox15", 208, 192, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox16 = GUICtrlCreateCheckbox("Checkbox16", 208, 224, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
;;;;
;;;NEW Section BBT
;;;;
$tab2 = GUICtrlCreateTabItem("BBT")
;;;;
;;;NEW Section ADD
;;;;
$TabSheet1 = GUICtrlCreateTabItem("ADD")
GUICtrlCreateTabItem("")
$output1 = GUICtrlCreateInput("pris per måned", 392, 64, 121, 24)
$output2 = GUICtrlCreateInput("Etablerinskostnad", 392, 128, 121, 24)
$Label1 = GUICtrlCreateLabel("Etableringskostnad", 392, 104, 120, 20)
$Label2 = GUICtrlCreateLabel("Pris per måned", 400, 40, 95, 20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

#2-Ini check

If FileExists(@ScriptDir &"\" & "InformationFile.INI") Then
    MsgBox(4096, "C:\autoexec.bat File", "Exists")
Else
    MsgBox(4096,"=Checking= InformationFile", "The file does NOT exists"&@CRLF &"Creating new Pricefile."&@CRLF &"please adjust the prices accordingly as it will use an old value"&@CRLF &"Best Regards" &@CRLF &"Andreas N Walseng")

IniWriteSection("InformationFile.INI","subscriptions IPTV","")

IniWrite("InformationFile.INI","subscriptions IPTV","Basis  "," 178")
IniWrite("InformationFile.INI","subscriptions IPTV","CDM    "," 130")
IniWrite("InformationFile.INI","subscriptions IPTV","CDP    "," 350")
IniWrite("InformationFile.INI","subscriptions IPTV","C+S    "," 269")
IniWrite("InformationFile.INI","subscriptions IPTV","C+F    "," 209")
IniWrite("InformationFile.INI","subscriptions IPTV","C+T    "," 289")
IniWrite("InformationFile.INI","subscriptions IPTV","VFA    "," 120")
IniWrite("InformationFile.INI","subscriptions IPTV","VDN    "," 99")
IniWrite("InformationFile.INI","subscriptions IPTV","VBU    "," 99")
IniWrite("InformationFile.INI","subscriptions IPTV","VS "," 199")
IniWrite("InformationFile.INI","subscriptions IPTV","VF "," 199")
IniWrite("InformationFile.INI","subscriptions IPTV","VSF    "," 249")
IniWrite("InformationFile.INI","subscriptions IPTV","TV2BPL "," 199")
IniWrite("InformationFile.INI","subscriptions IPTV","TV2S   "," 169")
IniWrite("InformationFile.INI","subscriptions IPTV","TV2SBPL    "," 299")
IniWrite("InformationFile.INI","subscriptions IPTV","",@CRLF)
IniWriteSection("InformationFile.INI","Subscriptions FiBer","")
IniWrite("InformationFile.INI","Subscriptions FiBer","Medium    "," 449")
IniWrite("InformationFile.INI","Subscriptions FiBer","Premium   "," 549")
IniWrite("InformationFile.INI","Subscriptions FiBer","Max   "," 1390")
#cs
[Subscriptions BBT]

[Additional Packages]
#ce

EndIf

Edit: i could go for something like this right? the msgboxes are just for test purpose. but is there a way to have it not needed to hit the button1 to see the results?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\andreas\documents\_2.kxf
$_2 = GUICreate("Test Kalkulator", 516, 384, 352, 159)
GUISetFont(9, 400, 0, "MS Sans Serif")
GUISetBkColor(0xFFFBF0)
$tab = GUICtrlCreateTab(10, 18, 376, 324, $TCS_HOTTRACK)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tab0 = GUICtrlCreateTabItem("FIBER")
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 88, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 24, 120, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 24, 152, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 24, 184, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$tab1 = GUICtrlCreateTabItem("IPTV")
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 32, 64, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox6 = GUICtrlCreateCheckbox("Checkbox6", 32, 96, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox7 = GUICtrlCreateCheckbox("Checkbox7", 32, 128, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox8 = GUICtrlCreateCheckbox("Checkbox8", 32, 160, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox9 = GUICtrlCreateCheckbox("Checkbox9", 32, 192, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox10 = GUICtrlCreateCheckbox("Checkbox10", 32, 224, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox11 = GUICtrlCreateCheckbox("Checkbox11", 208, 64, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox12 = GUICtrlCreateCheckbox("Checkbox12", 208, 96, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox13 = GUICtrlCreateCheckbox("Checkbox13", 208, 128, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox14 = GUICtrlCreateCheckbox("Checkbox14", 208, 160, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox15 = GUICtrlCreateCheckbox("Checkbox15", 208, 192, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Checkbox16 = GUICtrlCreateCheckbox("Checkbox16", 208, 224, 97, 17)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFBF0)
$tab2 = GUICtrlCreateTabItem("BBT")
$TabSheet1 = GUICtrlCreateTabItem("ADD")
GUICtrlCreateTabItem("")
$output1 = GUICtrlCreateInput("pris per måned", 392, 64, 121, 24)
$output2 = GUICtrlCreateInput("Etablerinskostnad", 392, 128, 121, 24)
$Label1 = GUICtrlCreateLabel("Etableringskostnad", 392, 104, 120, 20)
$Label2 = GUICtrlCreateLabel("Pris per måned", 400, 40, 95, 20)
$Button1 = GUICtrlCreateButton("Button1", 408, 200, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
        Case $Button1
            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-1 has been checked")
            EndIf
            If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-2 has been checked")
            EndIf
            If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-3 has been checked")
            EndIf
            If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-4 has been checked")
            EndIf
            If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-5 has been checked")
            EndIf
            If GUICtrlRead($Checkbox6) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-6 has been checked")
            EndIf
            If GUICtrlRead($Checkbox7) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-7 has been checked")
            EndIf
            If GUICtrlRead($Checkbox8) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-8 has been checked")
            EndIf
            If GUICtrlRead($Checkbox9) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-9 has been checked")
            EndIf
            If GUICtrlRead($Checkbox10) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-10 has been checked")
            EndIf
            If GUICtrlRead($Checkbox11) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-11 has been checked")
            EndIf
            If GUICtrlRead($Checkbox12) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-12 has been checked")
            EndIf
            If GUICtrlRead($Checkbox13) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-13 has been checked")
            EndIf
            If GUICtrlRead($Checkbox14) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-14 has been checked")
            EndIf
            If GUICtrlRead($Checkbox15) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-15 has been checked")
                EndIf
                If GUICtrlRead($Checkbox16) = $GUI_CHECKED Then
                MsgBox(0, "test", "Check-15 has been checked")
            EndIf
            ;Deselect items after Buttonclick
            If $GUI_CHECKED = 1 Then
                GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox5, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox6, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox7, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox8, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox9, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox10, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox11, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox12, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox13, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox14, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox15, $GUI_UNCHECKED)
                GUICtrlSetState($Checkbox16, $GUI_UNCHECKED)
            EndIf


EndSwitch
WEnd
Edited by pezo89

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Nice, that works Zedna, thanks alot. (did't know it was possible to refer to a checkbox)

any idea on how to do the calculation part? add when checked, substract when unchecked and do no changes on the value before checking, so unchecked but not touched wont substract a value

Edited by pezo89

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTab.au3>

$ini=@ScriptDir & "\InformationFile.INI"
$main=GUICreate("Test",516, 384, 352, 159)
$output1 = GUICtrlCreateInput("pris per maned", 392, 64, 121, 24)
$tab=GUICtrlCreateTab(10, 18, 376, 324)
$sections=IniReadSectionNames($ini)
Global $tabs[$sections[0]+1]
For $i=1 To $sections[0]
    $tabs[$i]=GUICtrlCreateTabItem($sections[$i])
Next
For $i=1 To $sections[0]
    GUISwitch($main,$tabs[$i])
    $data=IniReadSection($ini,$sections[$i])
    For $j=1 To $data[0][0]
        $last=GUICtrlCreateCheckbox($data[$j][0],20,40+21*($j-1))
    Next
Next
GUISetState()
While 1
    $msg=GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
        Case $tabs[$sections[0]] To $last
            $text=_GUICtrlTab_GetItemText (GUICtrlGetHandle($tab),GUICtrlRead($tab))
            $section_data=IniRead($ini,$text,GUICtrlRead($msg,1),"")
            ConsoleWrite("value=" & $section_data & @CRLF)
            If BitAND(GUICtrlRead($msg),$GUI_CHECKED)=$GUI_CHECKED Then ;<<<<<<<< if checked add
            GUICtrlSetData($output1,GUICtrlRead($output1)+$section_data)
        ElseIf BitAND(GUICtrlRead($msg),$GUI_UNCHECKED)=$GUI_UNCHECKED Then ;<<<<<<<< if unchecked subtract
            GUICtrlSetData($output1,GUICtrlRead($output1)-$section_data)
        EndIf
EndSwitch
WEnd
Edited by ahmet

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Wow, it works like a charm!

just need to tweek it alittle bit =)

Thanks alot Ahmet! :huh2:

it works. but not much room for adjustments is it?

had to set up the ui around it (personal opinion)

Edited by pezo89

Share this post


Link to post
Share on other sites

how can i add more sections to the code?

first thought where changing the +nr`?

in this line?

Global $tabs[$sections[0]+1]

Share this post


Link to post
Share on other sites

Just add sections to ini file.

Share this post


Link to post
Share on other sites

Just add sections to ini file.

i tried that, but when i do that it wont start up the code.

C:\Users\Andreas\Desktop\Autoit Scrips\Fiber-Calc\New folder\test.au3 (66) : ==> Subscript used with non-Array variable.:
For $j=1 To $data[0][0]
For $j=1 To $data^ ERROR
->20:20:38 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 1.939

Share this post


Link to post
Share on other sites

i also tried just using my originial code

and it works just adding

GUICtrlSetData($output1,GUICtrlRead($output1)+IniRead("InformationFile.INI","subscriptions IPTV","Basis","5"))

as an action when checking a checkbox, hower that wont reset it when i uncheck it lol :huh2:

both codes does the job great,

but urs is abit harder to configure to fit the ui with =P

Share this post


Link to post
Share on other sites

To add or subtract value you need to check whether checkbox after click is checked or unchecked. I have updated my example look at '<<<<<<<<' lines.

In order for For loop to work sections mustn't be empty.

What do you mean my code is abit harder to configure to fit the ui with?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

ahh it's working now, forgot to just add the line in the ini file.

and the buttons aswell :huh2:

well for example what is the ID for the boxes that is made?.

as i need to have some boxes beeing checked when the program starts, and grey out others when some spesific ones are checked. ?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTab.au3>
;;Check If .INI is there, if not make a new one
If FileExists(@ScriptDir &"\" & "InformationFile.INI") Then

Else
    MsgBox(4096,"=Checking= InformationFile", "The file does NOT exists"&@CRLF &"Creating new Pricefile."&@CRLF &"please adjust the prices accordingly as it will use an old value"&@CRLF &"Best Regards" &@CRLF &"Andreas N Walseng")

IniWriteSection("InformationFile.INI","IPTV","")

IniWrite("InformationFile.INI","IPTV","Basis"," 178")
IniWrite("InformationFile.INI","IPTV","CDM","   130")
IniWrite("InformationFile.INI","IPTV","CDP","   350")
IniWrite("InformationFile.INI","IPTV","C+S","   269")
IniWrite("InformationFile.INI","IPTV","C+F","   209")
IniWrite("InformationFile.INI","IPTV","C+T","   289")
IniWrite("InformationFile.INI","IPTV","VFA","   120")
IniWrite("InformationFile.INI","IPTV","VDN","   99")
IniWrite("InformationFile.INI","IPTV","VBU","   99")
IniWrite("InformationFile.INI","IPTV","VS   "," 199")
IniWrite("InformationFile.INI","IPTV","VF   "," 199")
IniWrite("InformationFile.INI","IPTV","VSF","   249")
IniWrite("InformationFile.INI","IPTV","TV2BPL","    199")
IniWrite("InformationFile.INI","IPTV","TV2S","  169")
IniWrite("InformationFile.INI","IPTV","TV2SBPL","   299")

IniWriteSection("InformationFile.INI","FIBER","")
IniWrite("InformationFile.INI","FIBER","Medium","   449")
IniWrite("InformationFile.INI","FIBER","Premium","  549")
IniWrite("InformationFile.INI","FIBER","Max","  1390")

;IniWriteSection("InformationFile.INI","Subscriptions BBT","")
#cs
[Additional Packages]
#ce

EndIf

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>


local $info

$ini=@ScriptDir & "\InformationFile.INI"
$main=GUICreate("Test Calc-mnd's abo",516, 384, 352, 159)
$output1 = GUICtrlCreateInput("pris per mned", 392, 64, 121, 24)
$output2 = GUICtrlCreateInput("ETABLERING", 392, 90, 121, 24)
$tab=GUICtrlCreateTab(10, 18, 376, 400)
$Button2 = GUICtrlCreateButton("HC/Greenfield", 400, 240, 123, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("HP/BrownField", 400, 296, 123, 25, $WS_GROUP)
$Info = GUICtrlCreateButton("INFO", 400,340, 123, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Etablering -299,-", 416, 216, 100, 20)
$Label2 = GUICtrlCreateLabel("Etablering 1990,-", 416, 272, 103, 20)
$Label3 = GUICtrlCreateLabel("Fungerer ikke ennå", 400, 180, 100, 20)
$sections=IniReadSectionNames($ini)
Global $tabs[$sections[0]+1]
For $i=1 To $sections[0]
    $tabs[$i]=GUICtrlCreateTabItem($sections[$i])
Next
For $i=1 To $sections[0]
    GUISwitch($main,$tabs[$i])
    $data=IniReadSection($ini,$sections[$i])
    For $j=1 To $data[0][0]
        $last=GUICtrlCreateCheckbox($data[$j][0],20,40+21*($j-1))
    Next

Next
GUISetState()

While 1
    $msg=GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
        Case $tabs[$sections[0]] To $last
            $text=_GUICtrlTab_GetItemText (GUICtrlGetHandle($tab),GUICtrlRead($tab))
            $section_data=IniRead($ini,$text,GUICtrlRead($msg,1),"")
            ConsoleWrite("value=" & $section_data & @CRLF)
            If BitAND(GUICtrlRead($msg),$GUI_CHECKED)=$GUI_CHECKED Then
            GUICtrlSetData($output1,GUICtrlRead($output1)+$section_data)
        ElseIf BitAND(GUICtrlRead($msg),$GUI_UNCHECKED)=$GUI_UNCHECKED Then
            GUICtrlSetData($output1,GUICtrlRead($output1)-$section_data)
        EndIf

    Case $Button2
        GUICtrlSetData($output2,GUICtrlRead($output2)-"299")

        Case $Button3
        GUICtrlSetData($output2,GUICtrlRead($output2)-"1990")


    Case $info
        #Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info, Modality=Task Modal
MsgBox(8256,"Information","ingenting her ennå",
#EndRegion --- CodeWizard generated code End ---

    EndSwitch

WEnd
Edited by pezo89

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I was bored, so i thought i test the script!

A thing i noticed:

MsgBox(8256,"Information","ingenting her ennå")

I removed the , and added the missing parentasees (is that the correct spelling?)

Also regarding the buttons that doesnt work, is it supposed to be like, when you click it it adds the value, then when you click it again it removes that value again ?

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

Also:

local $info

$ini=@ScriptDir & "\InformationFile.INI"
$main=GUICreate("Test Calc-mnd's abo",516, 384, 352, 159)
$output1 = GUICtrlCreateInput("pris per mned", 392, 64, 121, 24)
$output2 = GUICtrlCreateInput("ETABLERING", 392, 90, 121, 24)
$tab=GUICtrlCreateTab(10, 18, 376, 400)
$Button2 = GUICtrlCreateButton("HC/Greenfield", 400, 240, 123, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("HP/BrownField", 400, 296, 123, 25, $WS_GROUP)
$Info = GUICtrlCreateButton("INFO", 400,340, 123, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Etablering -299,-", 416, 216, 100, 20)
$Label2 = GUICtrlCreateLabel("Etablering 1990,-", 416, 272, 103, 20)
$Label3 = GUICtrlCreateLabel("Fungerer ikke ennå", 400, 180, 100, 20)
$sections=IniReadSectionNames($ini)

$output1 = GUICtrlCreateInput("pris per mned", 392, 64, 121, 24)

should be "Pris per måned"


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Here is the new loop for checking the checkboxes

Global $defaults[2]=["CDM","CDP"]
For $i = 1 To $sections[0]
    GUISwitch($main, $tabs[$i])
    $data = IniReadSection($ini, $sections[$i])
    For $j = 1 To $data[0][0]
        $last = GUICtrlCreateCheckbox($data[$j][0], 20, 40 + 21 * ($j - 1))
        For $k = 0 To UBound($defaults) - 1
            If $data[$j][0] = $defaults[$k] Then
                GUICtrlSetState($last, $GUI_CHECKED)
                ExitLoop
            EndIf
        Next
    Next
Next

Try to make to add prices of checked checkboxses.

@Maffe811:

Spelling is "parenthesis" :huh2:

Edit:There was an error in example.

Edited by ahmet

Share this post


Link to post
Share on other sites

@Maffe811:

Spelling is "parenthesis" ;)

Thanks :huh2:

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

il check it tomorrow Ahmet, got work in 6 hours, so Good night fellas ;)

And again To all involved, thanks alot! :huh2:

Share this post


Link to post
Share on other sites

but how are they defined after created from the inifile?

ie. how can i for example say checkbox 1 is checked,

then

have GUICtrlSetState ( controlID <<?, $GUI_DISABLE)

on one of the others that i need to grey out?

like that is the Controler id on those buttons?

Share this post


Link to post
Share on other sites

I'm not sure if this is what you are asking, but GUICtrlGetState will get you the checked state of the boxes.

Share this post


Link to post
Share on other sites

I haven't added vaiable for every checkbox. Look for

Case $tabs[$sections[0]] To $last

That line triggers 'event' for each checkbox. There you will see If...ElseIf...Else...EndIf. I hope this helps.

Share this post


Link to post
Share on other sites

I haven't added vaiable for every checkbox. Look for

Case $tabs[$sections[0]] To $last

That line triggers 'event' for each checkbox. There you will see If...ElseIf...Else...EndIf. I hope this helps.

well i thought every checkbox that is made has an id linked to it, so ie i can make

just a draft, not operational code but it should give you and idea what im after

so what im after is what to exchange $checkbox line with,

Case $Button3

GUICtrlSetData($output2,GUICtrlRead($output2)-"1990")

GUICtrlSetState($checkbox[2],$GUI_CHECKED)

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