![]() |
Clomosy Resmi Forum Sitesidir. Amacımız kullanıcılarımıza, iş ortaklarımıza, danışmanlara, yazılımcılara programlarımız hakkında destek ve bilgi vermektir. |
|
Yanıt Yaz ![]() |
Yazar | |
NadireNurSaglam ![]() Yeni Üye ![]() Kayıt Tarihi: 08 Ağustos 2024 Durum: Aktif Değil Puanlar: 37 |
![]() Gönderim Zamanı: 13 Ağustos 2024 Saat 12:26 |
Merhaba. StringListNew kullanırken
harfListesi[k] = harfListesi[RandomIndex]; satırında index hatası alıyorum. Nasıl çözebilirim? Teşekkürler. ------------------------------------------
RUNTİME ERROR List index out of bounds (4). TStringList range is 02 when evaluating instruction CallProc Stack content is: Source position: 39,49 Position: 39, 49,
--------------------------------------------- var MyForm,baslaForm,oyunForm: TclForm; arkaPlanImg: TCLImage; baslaButon,nasiloynanirButon,fruitsButon,animalsButon,colorsButon,jobsButon,tahminEtProButton : TClProButton; fruitsList,animalsList,colorsList,jobsList: TclStringList; kelimeProLabel, kategoriProLabel,karistirilmisProLabel,tahminetProLabel: TClProLabel; tahminProEdit: TclProEdit; karisikKelime,TempChar: String; harfListesi: TclStringList; j, k,i, RandomIndex: Integer; function kelimeleriKaristir(List:TclStringList); { i = 0; while (i < List.Count) { harfListesi = Clomosy.StringListNew; harfListesi.Capacity = 10; j = 0; while (j < Length(List)) { harfListesi.Add(Copy(List, j + 1, 1)); j = j + 1; } k = 0; while (k < harfListesi.Count) { RandomIndex = Round(Random() * ((harfListesi.Count)+1)); //ShowMessage(RandomIndex); //ShowMessage(harfListesi[RandomIndex]); TempChar = harfListesi[k] ; harfListesi[k] = harfListesi[RandomIndex]; harfListesi[RandomIndex] = TempChar; k = k + 1; } karisikKelime = ''; k = 0; while (k < harfListesi.Count) { karisikKelime = karisikKelime + harfListesi[k]; k = k + 1; } ShowMessage(karisikKelime); } } void tahminEtButonClick; { ShowMessage('oldu'); } void KategoriSecimi; { oyunForm = TCLForm.Create(Self); oyunForm.SetFormBGImage('https://i.imgur.com/0ozkr4m.png'); karistirilmisProLabel = oyunForm.AddNewProLabel(oyunForm,'karistirilmisProLabel','KELİMENİN KARIŞTIRILMIŞ HALİ:'); clComponent.SetupComponent(karistirilmisProLabel,'{ "Align":"Center", "MarginBottom" : 550, "Width":400, "Height" :300, "TextSize" : 25, "TextVerticalAlign": "Center", "TextHorizontalAlign" :"Center", "TextBold": "Yes" }') kelimeProLabel = oyunForm.AddNewProLabel(oyunForm, 'kelimeProLabel', 'Label'); clComponent.SetupComponent(kelimeProLabel,'{ "Align" : "Center", "MarginBottom":350, "Width":340, "Height":60, "TextSize" :25, "TextHorizontalAlign " : "Center", "TextVerticalAlign" : "Center", "TextBold":"Yes", "BackgroundColor":"#fefbec", "RoundHeight":8, "RoundWidth":8, "BorderColor":"#94ae89", "BorderWidth":2 }') tahminetProLabel = oyunForm.AddNewProLabel(oyunForm,'tahminetProLabel','TAHMİN ET:'); clComponent.SetupComponent(tahminetProLabel,'{ "Align":"Center", "MarginBottom" : 120, "Width":400, "Height" :300, "TextSize" : 25, "TextVerticalAlign": "Center", "TextHorizontalAlign" :"Center", "TextBold": "Yes" }') tahminProEdit = oyunForm.AddNewProEdit(oyunForm, 'tahminProEdit', 'Tahminini Gir...'); clComponent.SetupComponent(tahminProEdit,'{ "Align" : "Center", "MarginTop":80, "Width":340, "Height":60, "TextSize" :25, "TextHorizontalAlign " : "Center", "TextVerticalAlign" : "Center", "TextBold":"Yes", "BackgroundColor":"#fefbec", "RoundHeight":8, "RoundWidth":8, "BorderColor":"#94ae89", "BorderWidth":2 }') tahminProEdit.clTypeOfField = taString; //sadece metin girişi tahminEtProButton = oyunForm.AddNewProButton(oyunForm, 'tahminEtProButton', 'KONTROL ET'); clComponent.SetupComponent(tahminEtProButton, '{ "Align" : "Center", "TextSize":15, "MarginTop" : 320, "MarginLeft":200, "Width" : 200, "Height" : 50, "RoundHeight" : 8, "RoundWidth" : 8, "BackgroundColor":"#fefbec", "BorderColor":"#94ae89", "BorderWidth" : 2 }'); oyunForm.AddNewEvent(tahminEtProButton,tbeOnClick,'tahminEtButonClick'); oyunForm.Run; } void fruitsButonClick; { fruitsList = Clomosy.StringListNew; fruitsList.Capacity = 10; fruitsList.Add('apple'); fruitsList.Add('banana'); fruitsList.Add('orange'); fruitsList.Add('mango'); fruitsList.Add('watermelon'); fruitsList.Add('cherry'); fruitsList.Add('lemon'); fruitsList.Add('strawberry'); fruitsList.Add('grape'); fruitsList.Add('pineapple'); kelimeleriKaristir(fruitsList); KategoriSecimi; } void animalsButonClick; { animalsList = Clomosy.StringListNew; animalsList.Capacity = 10; animalsList.Add('cat'); animalsList.Add('dog'); animalsList.Add('elephant'); animalsList.Add('tiger'); animalsList.Add('lion'); animalsList.Add('giraffe'); animalsList.Add('zebra'); animalsList.Add('monkey'); animalsList.Add('bear'); animalsList.Add('dolphin'); kelimeleriKaristir(animalsList); KategoriSecimi; } void colorsButonClick; { colorsList = Clomosy.StringListNew; colorsList.Capacity = 10; colorsList.Add('red'); colorsList.Add('blue'); colorsList.Add('green'); colorsList.Add('yellow'); colorsList.Add('black'); colorsList.Add('white'); colorsList.Add('pink'); colorsList.Add('orange'); colorsList.Add('purple'); colorsList.Add('brown'); kelimeleriKaristir(colorsList); KategoriSecimi; } void jobsButonClick; { jobsList = Clomosy.StringListNew; jobsList.Capacity = 10; jobsList.Add('doctor'); jobsList.Add('teacher'); jobsList.Add('engineer'); jobsList.Add('nurse'); jobsList.Add('lawyer'); jobsList.Add('architect'); jobsList.Add('chef'); jobsList.Add('artist'); jobsList.Add('police'); jobsList.Add('journalist'); kelimeleriKaristir(jobsList); KategoriSecimi; } void baslaButonClick; { baslaForm = TCLForm.Create(Self); baslaForm.SetFormBGImage('https://i.imgur.com/QdZNWrx.png'); kategoriProLabel = baslaForm.AddNewProLabel(baslaForm,'kategoriProLabel','HADİ BİR KATEGORİ SEÇ VE TAHMİN ETMEYE BAŞLA!'); clComponent.SetupComponent(kategoriProLabel,'{ "Align":"Center", "MarginBottom" : 520, "Width":400, "Height" :300, "TextSize" : 25, "TextVerticalAlign": "Center", "TextHorizontalAlign" :"Center", "TextBold": "Yes" }') fruitsButon = baslaForm.AddNewProButton(baslaForm, 'fruitsButon', 'Fruits'); clComponent.SetupComponent(fruitsButon, '{ "Align" : "Center", "TextSize":20, "MarginBottom" : 150, "MarginRight":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(fruitsButon,tbeOnClick,'fruitsButonClick'); //------------------------------------------------------------------------------- animalsButon = baslaForm.AddNewProButton(baslaForm, 'animalsButon', 'Animals'); clComponent.SetupComponent(animalsButon, '{ "Align" : "Center", "TextSize":20, "MarginBottom" : 150, "MarginLeft":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(animalsButon,tbeOnClick,'animalsButonClick'); //-------------------------------------------------------------------------- colorsButon = baslaForm.AddNewProButton(baslaForm, 'colorsButon', 'Colors'); clComponent.SetupComponent(colorsButon, '{ "Align" : "Center", "TextSize":20, "MarginTop" : 250, "MarginRight":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(colorsButon,tbeOnClick,'colorsButonClick'); //-------------------------------------------------------------------- jobsButon = baslaForm.AddNewProButton(baslaForm, 'jobsButon', 'Jobs'); clComponent.SetupComponent(jobsButon, '{ "Align" : "Center", "TextSize":20, "MarginTop" : 250, "MarginLeft":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(jobsButon,tbeOnClick,'jobsButonClick'); //------------------------------------------------------------- baslaForm.Run; } void nasiloynanirButonClick; { ShowMessage('Guess What oyununa hoş geldiniz! Bu oyunda, karışık halde verilen harflerden anlamlı bir kelime oluşturmanız beklenmektedir. Oyunun amacı, verilen harfleri kullanarak doğru kelimeyi bulmaktır. Seçilen kategori ile ilgili gelen kelimenin harfleri karışık gelir. Ayrıca kelimeye ait olmayan harfler de bu karışık harflerin arasında yer alır. Haydi Başla butonuna tıkla, ardından bir kategori seç ve eğlenmeye başla!'); } { MyForm = TCLForm.Create(Self); MyForm.SetFormBGImage('https://i.imgur.com/rLwQoPD.png'); baslaButon = MyForm.AddNewProButton(MyForm, 'baslaButon', 'BAŞLA'); clComponent.SetupComponent(baslaButon, '{ "Align" : "Center", "TextSize":25, "MarginBottom" : 135, "Width" : 250, "Height" : 70, "RoundHeight" : 5, "RoundWidth" : 5, "Bordercolor" : "#8eaaad", "BorderWidth" : 2 }'); MyForm.AddNewEvent(baslaButon,tbeOnClick,'baslaButonClick'); nasiloynanirButon = MyForm.AddNewProButton(MyForm, 'nasiloynanirButon', 'NASIL OYNANIR?'); clComponent.SetupComponent(nasiloynanirButon, '{ "Align" : "Center", "TextSize":25, "MarginTop" : 40, "Width" : 250, "Height" : 70, "RoundHeight" : 5, "RoundWidth" : 5, "Bordercolor" : "#8eaaad", "BorderWidth" : 2 }'); MyForm.AddNewEvent(nasiloynanirButon,tbeOnClick,'nasiloynanirButonClick'); MyForm.Run; } |
|
![]() |
|
BilalCndn ![]() Forum Yöneticisi ![]() ![]() Kayıt Tarihi: 09 Ekim 2023 Durum: Aktif Değil Puanlar: 152 |
![]() |
Merhaba Nadire,
RandomIndex = Round(Random() * ((harfListesi.Count)+1)); Bu satırı aşağıdaki şekilde düzenler misin? RandomIndex = Round(Random(harfListesi.Count)); |
|
Bilal Candan
Atiker Yazılım Veri İşlem A.Ş. Software and Artificial Intelligence Development Specialist [email protected] |
|
![]() |
|
NadireNurSaglam ![]() Yeni Üye ![]() Kayıt Tarihi: 08 Ağustos 2024 Durum: Aktif Değil Puanlar: 37 |
![]() |
Teşekkür ederim. Bir sorum daha olacaktı. 'kelimeleriKaristir' fonksiyonundan elde ettiğim 'karisikKelime' değişkenini, 'KategoriSecimi' fonksiyonunda tanımlamış olduğum 'kelimeProLabel' nesnesinin içine nasıl yazabilirim?
Kodun son hali aşağıdaki gibidir: var MyForm,baslaForm,oyunForm: TclForm; arkaPlanImg: TCLImage; baslaButon,nasiloynanirButon,fruitsButon,animalsButon,colorsButon,jobsButon,tahminEtProButton : TClProButton; fruitsList,animalsList,colorsList,jobsList: TclStringList; kelimeProLabel, kategoriProLabel,karistirilmisProLabel,tahminetProLabel: TClProLabel; tahminProEdit: TclProEdit; karisikKelime,TempChar: String; harfListesi: TclStringList; j, k,i, RandomIndex: Integer; yedeklabel : TClProLabel; function kelimeleriKaristir(List:TclStringList); { i = 0; while (i < List.Count) { harfListesi = Clomosy.StringListNew; harfListesi.Capacity = 10; j = 0; while (j < Length(List)) { harfListesi.Add(Copy(List, j + 1, 1)); j = j + 1; } k = 0; while (k < harfListesi.Count) { RandomIndex = Round(Random(harfListesi.Count)); TempChar = harfListesi[k] ; harfListesi[k] = harfListesi[RandomIndex]; harfListesi[RandomIndex] = TempChar; k = k + 1; } karisikKelime = ''; k = 0; while (k < harfListesi.Count) { karisikKelime = karisikKelime + harfListesi[k]; k = k + 1; } //ShowMessage(karisikKelime); // kelimeProLabel.Caption =karisikKelime; } } void tahminEtButonClick; { ShowMessage('oldu'); } void KategoriSecimi; { oyunForm = TCLForm.Create(Self); oyunForm.SetFormBGImage('https://i.imgur.com/0ozkr4m.png'); karistirilmisProLabel = oyunForm.AddNewProLabel(oyunForm,'karistirilmisProLabel','KELİMENİN KARIŞTIRILMIŞ HALİ:'); clComponent.SetupComponent(karistirilmisProLabel,'{ "Align":"Center", "MarginBottom" : 550, "Width":400, "Height" :300, "TextSize" : 25, "TextVerticalAlign": "Center", "TextHorizontalAlign" :"Center", "TextBold": "Yes" }') kelimeProLabel = oyunForm.AddNewProLabel(oyunForm, 'kelimeProLabel', ''); clComponent.SetupComponent(kelimeProLabel,'{ "Align" : "Center", "MarginBottom":350, "Width":340, "Height":60, "TextSize" :25, "TextHorizontalAlign " : "Center", "TextVerticalAlign" : "Center", "TextBold":"Yes", "BackgroundColor":"#fefbec", "RoundHeight":8, "RoundWidth":8, "BorderColor":"#94ae89", "BorderWidth":2 }') tahminetProLabel = oyunForm.AddNewProLabel(oyunForm,'tahminetProLabel','TAHMİN ET:'); clComponent.SetupComponent(tahminetProLabel,'{ "Align":"Center", "MarginBottom" : 120, "Width":400, "Height" :300, "TextSize" : 25, "TextVerticalAlign": "Center", "TextHorizontalAlign" :"Center", "TextBold": "Yes" }') tahminProEdit = oyunForm.AddNewProEdit(oyunForm, 'tahminProEdit', 'Tahminini Gir...'); clComponent.SetupComponent(tahminProEdit,'{ "Align" : "Center", "MarginTop":80, "Width":340, "Height":60, "TextSize" :25, "TextHorizontalAlign " : "Center", "TextVerticalAlign" : "Center", "TextBold":"Yes", "BackgroundColor":"#fefbec", "RoundHeight":8, "RoundWidth":8, "BorderColor":"#94ae89", "BorderWidth":2 }') tahminProEdit.clTypeOfField = taString; //sadece metin girişi tahminEtProButton = oyunForm.AddNewProButton(oyunForm, 'tahminEtProButton', 'KONTROL ET'); clComponent.SetupComponent(tahminEtProButton, '{ "Align" : "Center", "TextSize":15, "MarginTop" : 320, "MarginLeft":200, "Width" : 200, "Height" : 50, "RoundHeight" : 8, "RoundWidth" : 8, "BackgroundColor":"#fefbec", "BorderColor":"#94ae89", "BorderWidth" : 2 }'); oyunForm.AddNewEvent(tahminEtProButton,tbeOnClick,'tahminEtButonClick'); oyunForm.Run; } void fruitsButonClick; { fruitsList = Clomosy.StringListNew; fruitsList.Capacity = 10; fruitsList.Add('apple'); fruitsList.Add('banana'); fruitsList.Add('orange'); fruitsList.Add('mango'); fruitsList.Add('watermelon'); fruitsList.Add('cherry'); fruitsList.Add('lemon'); fruitsList.Add('strawberry'); fruitsList.Add('grape'); fruitsList.Add('pineapple'); kelimeleriKaristir(fruitsList); KategoriSecimi; } void animalsButonClick; { animalsList = Clomosy.StringListNew; animalsList.Capacity = 10; animalsList.Add('cat'); animalsList.Add('dog'); animalsList.Add('elephant'); animalsList.Add('tiger'); animalsList.Add('lion'); animalsList.Add('giraffe'); animalsList.Add('zebra'); animalsList.Add('monkey'); animalsList.Add('bear'); animalsList.Add('dolphin'); kelimeleriKaristir(animalsList); KategoriSecimi; } void colorsButonClick; { colorsList = Clomosy.StringListNew; colorsList.Capacity = 10; colorsList.Add('red'); colorsList.Add('blue'); colorsList.Add('green'); colorsList.Add('yellow'); colorsList.Add('black'); colorsList.Add('white'); colorsList.Add('pink'); colorsList.Add('orange'); colorsList.Add('purple'); colorsList.Add('brown'); kelimeleriKaristir(colorsList); KategoriSecimi; } void jobsButonClick; { jobsList = Clomosy.StringListNew; jobsList.Capacity = 10; jobsList.Add('doctor'); jobsList.Add('teacher'); jobsList.Add('engineer'); jobsList.Add('nurse'); jobsList.Add('lawyer'); jobsList.Add('architect'); jobsList.Add('chef'); jobsList.Add('artist'); jobsList.Add('police'); jobsList.Add('journalist'); kelimeleriKaristir(jobsList); KategoriSecimi; } void baslaButonClick; { baslaForm = TCLForm.Create(Self); baslaForm.SetFormBGImage('https://i.imgur.com/QdZNWrx.png'); kategoriProLabel = baslaForm.AddNewProLabel(baslaForm,'kategoriProLabel','HADİ BİR KATEGORİ SEÇ VE TAHMİN ETMEYE BAŞLA!'); clComponent.SetupComponent(kategoriProLabel,'{ "Align":"Center", "MarginBottom" : 520, "Width":400, "Height" :300, "TextSize" : 25, "TextVerticalAlign": "Center", "TextHorizontalAlign" :"Center", "TextBold": "Yes" }') fruitsButon = baslaForm.AddNewProButton(baslaForm, 'fruitsButon', 'Fruits'); clComponent.SetupComponent(fruitsButon, '{ "Align" : "Center", "TextSize":20, "MarginBottom" : 150, "MarginRight":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(fruitsButon,tbeOnClick,'fruitsButonClick'); //------------------------------------------------------------------------------- animalsButon = baslaForm.AddNewProButton(baslaForm, 'animalsButon', 'Animals'); clComponent.SetupComponent(animalsButon, '{ "Align" : "Center", "TextSize":20, "MarginBottom" : 150, "MarginLeft":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(animalsButon,tbeOnClick,'animalsButonClick'); //-------------------------------------------------------------------------- colorsButon = baslaForm.AddNewProButton(baslaForm, 'colorsButon', 'Colors'); clComponent.SetupComponent(colorsButon, '{ "Align" : "Center", "TextSize":20, "MarginTop" : 250, "MarginRight":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(colorsButon,tbeOnClick,'colorsButonClick'); //-------------------------------------------------------------------- jobsButon = baslaForm.AddNewProButton(baslaForm, 'jobsButon', 'Jobs'); clComponent.SetupComponent(jobsButon, '{ "Align" : "Center", "TextSize":20, "MarginTop" : 250, "MarginLeft":200, "Width" : 170, "Height" : 170, "RoundHeight" : 8, "RoundWidth" : 8, "Bordercolor" : "#8eaaad", "BackgroundColor":"#fefbec", "BorderWidth" : 2 }'); baslaForm.AddNewEvent(jobsButon,tbeOnClick,'jobsButonClick'); //------------------------------------------------------------- baslaForm.Run; } void nasiloynanirButonClick; { ShowMessage('Guess What oyununa hoş geldiniz! Bu oyunda, karışık halde verilen harflerden anlamlı bir kelime oluşturmanız beklenmektedir. Oyunun amacı, verilen harfleri kullanarak doğru kelimeyi bulmaktır. Seçilen kategori ile ilgili gelen kelimenin harfleri karışık gelir. Ayrıca kelimeye ait olmayan harfler de bu karışık harflerin arasında yer alır. Haydi Başla butonuna tıkla, ardından bir kategori seç ve eğlenmeye başla!'); } { MyForm = TCLForm.Create(Self); MyForm.SetFormBGImage('https://i.imgur.com/rLwQoPD.png'); baslaButon = MyForm.AddNewProButton(MyForm, 'baslaButon', 'BAŞLA'); clComponent.SetupComponent(baslaButon, '{ "Align" : "Center", "TextSize":25, "MarginBottom" : 135, "Width" : 250, "Height" : 70, "RoundHeight" : 5, "RoundWidth" : 5, "Bordercolor" : "#8eaaad", "BorderWidth" : 2 }'); MyForm.AddNewEvent(baslaButon,tbeOnClick,'baslaButonClick'); nasiloynanirButon = MyForm.AddNewProButton(MyForm, 'nasiloynanirButon', 'NASIL OYNANIR?'); clComponent.SetupComponent(nasiloynanirButon, '{ "Align" : "Center", "TextSize":25, "MarginTop" : 40, "Width" : 250, "Height" : 70, "RoundHeight" : 5, "RoundWidth" : 5, "Bordercolor" : "#8eaaad", "BorderWidth" : 2 }'); MyForm.AddNewEvent(nasiloynanirButon,tbeOnClick,'nasiloynanirButonClick'); MyForm.Run; } |
|
![]() |
|
NadireNurSaglam ![]() Yeni Üye ![]() Kayıt Tarihi: 08 Ağustos 2024 Durum: Aktif Değil Puanlar: 37 |
![]() |
Sorunu çözebildim. Teşekkürler.
|
|
![]() |
Yanıt Yaz ![]() |
|
Tweet |
Forum Atla | Forum İzinleri ![]() Kapalı Foruma Yeni Konu Gönderme Kapalı Forumdaki Konulara Cevap Yazma Kapalı Forumda Cevapları Silme Kapalı Forumdaki Cevapları Düzenleme Kapalı Forumda Anket Açma Kapalı Forumda Anketlerde Oy Kullanma |