![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
||||
|
||||
![]() Вот кусок кода:
... procedure TForm1.Button1Click(Sender: TObject); var count:integer; sFile: string; Ini: TIniFile; begin if not FileExists(sFile) then begin Ini:=TIniFile.Create('D:\test.ini'); Ini.WriteInteger('General', 'count', 0); Ini.Free; end; sFile := 'D:\test.ini'; if FileExists(sFile) then begin Ini := TIniFile.Create(sFile); Ini.ReadInteger('General', 'count', count); count:=count+1; Ini.WriteInteger('General', 'count', count); {или так Ini.WriteInteger('General', 'count', count+1); никакой разницы} Ini.Free; end; end; ... Здесь не обновляется count всё время устанавливает в одной проге 1, а тут Ну почему ??? ![]() И выводит ![]() count=4357785 Ну помогите разобраться ![]() |
#2
|
||||
|
||||
![]() Нужно просто было правильно объявить переменную count.
Код:
... var Form1: TForm1; count:integer=0; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var sFile: string; Ini: TIniFile; begin if not FileExists(sFile) then begin Ini:=TIniFile.Create('D:\test.ini'); Ini.WriteInteger('General', 'count', 0); Ini.Free; end; sFile := 'D:\test.ini'; if FileExists(sFile) then begin Ini := TIniFile.Create(sFile); Ini.ReadInteger('General', 'count', count); count:=count+1; Ini.WriteInteger('General', 'count', count); {èëè òàê Ini.WriteInteger('General', 'count', count+1); íèêàêîé ðàçíèöû} Ini.Free; end; end; Кому я должен - всем прощаю!!!! ![]() |
#3
|
||||
|
||||
![]() В одном случае помогло, в другом нет. Не добавляет строку, не изменяте count
![]() Что же не так ? |
#4
|
||||
|
||||
![]() Поподробнее опиши свою проблему. С того что ты написал, я ничо не понял.
Кому я должен - всем прощаю!!!! ![]() |
#5
|
||||
|
||||
![]() Может так:
Код:
procedure TForm1.Button1Click(Sender: TObject); var sFile: string; Ini: TIniFile; count:integer; begin if not FileExists(sFile) then begin Ini:=TIniFile.Create('D:\test.ini'); count:=0; Ini.WriteInteger('General', 'count', 0); Ini.Free; end; sFile := 'D:\test.ini'; if FileExists(sFile) then begin Ini := TIniFile.Create(sFile); Ini.ReadInteger('General', 'count', count); count:=count+1; Ini.WriteInteger('General', 'count', count); {èëè òàê Ini.WriteInteger('General', 'count', count+1); íèêàêîé ðàçíèöû} Ini.Free; end; end; Кому я должен - всем прощаю!!!! ![]() |
#6
|
||||
|
||||
![]() ...
var Form1: TForm1; count:integer=0; implementation {$R *.dfm} procedure TForm1.Timer1Timer(Sender: TObject); var sFile: string; Ini: TIniFile; begin if not FileExists(sFile) then begin Ini:=TIniFile.Create('D:\test.ini'); Ini.WriteInteger('General', 'count', 0); Ini.Free; end; sFile := 'D:\test.ini'; if FileExists(sFile) then begin Ini := TIniFile.Create(sFile); Ini.ReadInteger('General', 'count', count); Ini.WriteInteger('General', 'count', count+1); Ini.Free; end; end; Почему не работает таймер, когда кнопка, то всё работат. Помогите разобраться... ![]() Последний раз редактировалось Oleg, 22.12.2007 в 11:47. |