Read checkbox from ini

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ca10c3sar
Newbie
Posts: 16
Joined: Thu Apr 13, 2017 7:36 pm

Read checkbox from ini

Post by ca10c3sar » Tue Jan 07, 2020 5:16 pm

How do i change the checkbox checked value depending on value from a ini?
I've tried this way below, but not worked

When a checkbox has checked value it display on code:
Checked = True
State = cbChecked

I've tried store those values on the ini and load it in the var

Checked = P1
State = P2

My ini has:
[PET]
PET_CHECKED_VALUE=True

ReadIniFile>C:\Users\CAIO\Documents\Macro Scheduler 14\REFILL\DIALOG.ini,PET,PET_CHECKED_VALUE,P
If>P=True
Let>P2=cbChecked
Endif

If>P=False
Let>P2=cbUnchecked
EndIf

Code: Select all

ReadIniFile>C:\Users\CAIO\Documents\Macro Scheduler 14\REFILL\DIALOG.ini,PET,PET_CHECKED_VALUE,P
If>P=True
  Let>P2=cbChecked
Endif

If>P=False
  Let>P2=cbUnchecked
EndIf

  
Dialog>Dialog1
object Dialog1: TForm
  Left = 361
  Top = 284
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  ClientHeight = 203
  ClientWidth = 586
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -14
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 120
  TextHeight = 16
  object PET: TLabel
    Left = 40
    Top = 13
    Width = 27
    Height = 16
    Caption = 'PET'
  end
  object CheckBox1: TCheckBox
    Left = 80
    Top = 13
    Width = 97
    Height = 17
    Checked = P1
    State = P2
    TabOrder = 8
  end
  object tMSButton
    Left = 35
    Top = 132
    Width = 86
    Height = 25
    ModalResult = 1
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Read checkbox from ini

Post by hagchr » Wed Jan 08, 2020 12:09 pm

Hi, Not sure of the State property right now but if you just use SetDialogProperty> to set the Checked property to True/False, and then show the Dialog, it should work.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 361
  Top = 284
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  ClientHeight = 203
  ClientWidth = 586
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -14
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 120
  TextHeight = 16
  object PET: TLabel
    Left = 40
    Top = 13
    Width = 27
    Height = 16
    Caption = 'PET'
  end
  object CheckBox1: TCheckBox
    Left = 80
    Top = 13
    Width = 97
    Height = 17
    Checked = P1
    State = P2
    TabOrder = 8
  end
  object tMSButton
    Left = 35
    Top = 132
    Width = 86
    Height = 25
    ModalResult = 1
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

ReadIniFile>C:\Users\CAIO\Documents\Macro Scheduler 14\REFILL\DIALOG.ini,PET,PET_CHECKED_VALUE,P

SetDialogProperty>Dialog1,Checkbox1,Checked,P
Show>Dialog1,res

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts