DivaneTR Posted May 6, 2012 Share Posted May 6, 2012 (edited) Parametre Destekli Program Yapımı Bu konuda sizlere AMS ile parametreyle çalışan program yapmayı göstereceğim. Hemen başlayalım ; if _CommandLineArgs[1] ~= nil and _CommandLineArgs[1] ~="" then Dialog.Message("Açılan dosya", _CommandLineArgs[1], MB_OK, MB_ICONNONE, MB_DEFBUTTON1); end Yukarıdaki kodları sayfamızın açılış evrelerinden birine yazdığımızda, örneğin bir dosyaya birlikte aç deyip, yaptığımız AMS programını gösterirsek, program açıldığında size seçtiğiniz dosyanın tam yolunu gösterecektir. Dosya yolunu öğrendikten sonra yapmak istediğiniz şeyler hayal gücünüzle doğru orantılıdır. Örneğin bir müzik dosyasını programınızla çaldırmak için vs. Bir diğer örneğimiz, parametreleri toplayıp görüntülemektir. _CommandLineArgs tablo olarak döner. Dolayısıyla bir döngü ile bunları alacağız. Örneğin ; for index, parametre in pairs(_CommandLineArgs) do Dialog.Message("Parametreler", "Command line argument\n"..index.." = "..parametre); end Yukarıdaki örnekte, diyelim programınızı /S parametresi ile çalıştırdınız. Vereceği cevap şu şekildedir ; Birden fazla parametreyle çalıştırırsak parametreleri ve index numaralarını sırayla mesaj olarak gösterecektir. Aldığımız parametreleri if-else yapısıyla da kullanabiliriz. Örneğin ; for index, parametre in pairs(_CommandLineArgs) do if parametre == "/kucult" then Window.Minimize(Application.GetWndHandle()); end end Yukarıda verilen kodlarda, eğer programımızı "/kucult" parametresiyle çalıştırırsak program açıldığı gibi görev çubuğuna küçülecektir. Bir diğer örnekte parametre ile programımızda müzik çaldıralım ; if _CommandLineArgs[1] ~= nil and _CommandLineArgs[1] ~="" then Split = String.SplitPath(_CommandLineArgs[1]); if Split.Extension == ".mp3" or Split.Extension == ".wma" then Audio.Load(CHANNEL_BACKGROUND, _CommandLineArgs[1], true, false); else Dialog.Message("Hata", "Bu bir müzik dosyası değildir", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1); end end Yukarıda verdiğim kodlara göre programı "Program.exe D:\\Muzik.mp3" parametresiyle çalıştırırsak program açıldığı gibi D konumundaki müzik dosyasını çalacaktır. Birlikte aç ile de aynı işlem yapılabilir, yine program açıldığı gibi müzik dosyasını çalacaktır. Anlatım bu kadardır. Soru ve görüşlerinizi, eklemek istediklerinizi konu altından yazabilirsiniz. Kolay gelsin. Edited August 3, 2013 by DivaneTR Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted May 6, 2012 Editor Share Posted May 6, 2012 Baba_ ek olarak şeyide ekleseydin bari.Komut işlenirken pencerenin gözükmemesi. Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted May 6, 2012 Author Share Posted May 6, 2012 On startup veya on preload kısmına eklersen zaten görünmez usta. Olmadı başka yerden anlatım yaparız Quote Link to comment Share on other sites More sharing options...
reyiz Posted August 2, 2013 Share Posted August 2, 2013 Bu koddaki hata nedir arkadaşlar? if (_CommandLineArgs) then komut = _CommandLineArgs[1] parametre = "/ontop" kontrol = String.Find(komut, parametre, 1, false); if kontrol ~= -1 then Application.Exit(0); end end Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 2, 2013 Author Share Posted August 2, 2013 Bu koddaki hata nedir arkadaşlar? if (_CommandLineArgs) then komut = _CommandLineArgs[1] parametre = "/ontop" kontrol = String.Find(komut, parametre, 1, false); if kontrol ~= -1 then Application.Exit(0); end end for index, parameter in pairs (_CommandLineArgs) do if parameter == "/ontop" then -- kodlar buraya end end Şu anda AMS yok ezbere yazdım ama sanırım yapı bu şekildeydi. Quote Link to comment Share on other sites More sharing options...
reyiz Posted August 2, 2013 Share Posted August 2, 2013 Çalışmadı maalesef. Kullandığım kodlar bunlar: for index, parameter in pairs (_CommandLineArgs) do if parameter == "/ontop" then Application.Exit(0); end end Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 3, 2013 Author Share Posted August 3, 2013 Proje dosyası verirseniz, daha iyi yardımcı olabilirim. Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted August 3, 2013 Editor Share Posted August 3, 2013 reyiz hangi event ta kullandın kodları. Quote Link to comment Share on other sites More sharing options...
reyiz Posted August 3, 2013 Share Posted August 3, 2013 Global'da kullandım. Proje dosyası verirseniz, daha iyi yardımcı olabilirim. Projede başka bir kod yok. Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 3, 2013 Author Share Posted August 3, 2013 Globalde kullanmayacaksın, On Startup ve On Preload eventlerinde kullan. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.