Jump to content

Dosya Olusturma Hakkinda


monika

Recommended Posts

Arkadaslar ben bi calisma yaptim ancak bi sorunum var Olusturdugum programda bi xml dosyasi olusturacak ve icerisine yazi yazacak bazi yerlerinide input a yazdigim yaziyi yazacak benim olusturdugum script de bazi hatalar var ama fazla bilgim yok eksik yerlerde yardim ede bilirmuisiniz

script

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 180, 72, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_close")
$Input1 = GUICtrlCreateInput("", 40, 8, 121, 21)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$start = GUICtrlCreateButton("Olustur", 64, 32, 75, 25)
GUICtrlSetOnEvent($start, "start")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("IP", 16, 8, 14, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $start
			$ARCHIV = GUICtrlRead($Input1)
			If $ARCHIV = "" Then
				MsgBox(-1, "File Extractor", "Hic Bisey Yapilamadi!")
			EndIf
			FileWrite("C:/extract/extract.xml", "<Buildfile version='1.1'>")
			FileWriteLine("C:/extract/extract.xml", "	<Action type='extract' archivePath='C:/extract/" & $ARCHIV & "' outputPath='Source' extractAll='YES' createXML='YES' xmlPath='Pack.xml' />")
			FileWriteLine("C:/extract/extract.xml", "</Buildfile>")
	EndSwitch
WEnd

Link to comment
Share on other sites

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

$Form1 = GUICreate("Form1", 180, 72, 192, 124)
$Input1 = GUICtrlCreateInput("", 40, 8, 121, 21)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$start = GUICtrlCreateButton("Olustur", 64, 32, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("IP", 16, 8, 14, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $start
			$ARCHIV = GUICtrlRead($Input1)
			If $ARCHIV = "" Then
				MsgBox(-1, "File Extractor", "Hic Bisey Yapilamadi!")
				ContinueCase
			EndIf
			FileWrite("C:/extract/extract.xml", "<Buildfile version='1.1'>" & @crlf & _
			"	<Action type='extract' archivePath='C:/extract/" & $ARCHIV & "' outputPath='Source' extractAll='YES' createXML='YES' xmlPath='Pack.xml' />" & @crlf & _
			"</Buildfile>")
	EndSwitch
WEnd

Inputa girdiğin bilgi xml dosyasında hep aynı yeremi yazılacak? Biraz daha detay vermelisin...

Link to comment
Share on other sites

oncelikle yanit verdigin icin tesekurler kardesim

inputa girdigim bilgi hep ayni yere yazilmicak farkli yerlerede yazacak ben inputa yazdigim bilgiyi okumasi icin inputu $ARCHIV = GUICtrlRead($Input1) bu sekilde adlandirdim yani $ARCHIV yazdigim her yerde inputa yazdigim bilgiyi girmesi lazim

Link to comment
Share on other sites

@monika

Ne yapmak istedini malesef anlamadım. :( Sana yardımcı olmam için biraz detaylı (xml örneği ile birlikte) anlatmalısın.

Tamam xml dosyasına bir veri yazdırmak istiyorsun lakin, inputa girilen bilgi nere yazılacak? Neye göre yazılacak?

Istersen www.autoitscript.com forumunda xml udflerine bak...

Neyse fazla yardımcı olamadık, kolay gelsin...

Link to comment
Share on other sites

tmm kardesim hallettik ancak 2 tane sorunum var 1.si inputtan 2 tane olusturdum ama 2 sine ayni yazi satirinda islem yapacak bunu yapamadim

2.si ise yazdirmak istedigim yaziyi dogru bi sekilde girmeme ragmen hata veriyor.

yeni kodlari vereyim

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 358, 238, 276, 192)
$Input1 = GUICtrlCreateInput("", 100, 80, 129, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Input2 = GUICtrlCreateInput("",  100, 160, 129, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$start = GUICtrlCreateButton("Olustur", 125, 200, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Server Ismi", 20, 80, 80, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
$Label2 = GUICtrlCreateLabel("IP", 20, 160, 78, 18)
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $start
			$ISIM = GUICtrlRead($Input1)
			If $ISIM = "" Then
				MsgBox(-1, "Serverinfo Olusturucu", "Server Ismini Yazmadiniz!")

			$IPNO = GUICtrlRead($Input2)
			If $IPNO = "" Then
				MsgBox(-1, "Serverinfo Olusturucu", "IP Numaranazini yazmadiniz!")
				ContinueCase
			EndIf
			FileWrite("C:/extract/serverinfo.py", "import app" & @crlf & _
			"import locale" & @crlf & _
			"import debugInfo" & @crlf & _
			"" & @crlf & _
			"CHINA_PORT = 50000" & @crlf & _
			"" & @crlf & _
			"app.ServerName = None" & @crlf & _
			"" & @crlf & _
			"if locale.IsGERMANY() or (locale.IsEUROPE() and app.GetLocalePath() == "locale/tr"):" & @crlf & _
			"	STATE_NONE = "Kapali"" & @crlf & _
			"" & @crlf & _
			"	STATE_DICT = {" & @crlf & _
			"		0 : "...."," & @crlf & _
			"		1 : "NORMAL"," & @crlf & _
			"		2 : "BUSY"," & @crlf & _
			"		3 : "FULL"" & @crlf & _
			"	}" & @crlf & _
			"" & @crlf & _
			"	NurhakMt2_serverinfo_Generator = {" & @crlf & _
			"		1:{"key":11,"name":"CH 1","ip":" & $IP & ","tcp_port":13000,"udp_port":13000,"state":STATE_NONE,},	" & @crlf & _
			"	}" & @crlf & _
			"" & @crlf & _
			"	REGION_NAME_DICT = {" & @crlf & _
			"		0 : "GERMANY"," & @crlf & _
			"	}" & @crlf & _
			"" & @crlf & _
			"	REGION_AUTH_SERVER_DICT = {" & @crlf & _
			"		0 : {" & @crlf & _
			"			1 : { "ip":" & $IP & ", "port":11002, }," & @crlf & _
			"		}," & @crlf & _
			"	}" & @crlf & _
			"" & @crlf & _
			"	REGION_DICT = {" & @crlf & _
			"		0 : {" & @crlf & _
			"			1 : { "name" : " & $ISIM & ", "channel" : NurhakMt2_serverinfo_Generator, }," & @crlf & _
			"		}," & @crlf & _
			"	}" & @crlf & _
			"" & @crlf & _
			"	MARKADDR_DICT = {" & @crlf & _
			"		10 : { "ip" : " & $IP & ", "tcp_port" : 13000, "mark" : "10.tga", "symbol_path" : "10", }," & @crlf & _
			"" & @crlf & _
			"" & @crlf & _
			"	}" & @crlf & _
			"" & @crlf & _
			"	TESTADDR = { "ip" : " & $ISIM & ", "tcp_port" : 50000, "udp_port" : 50000, }" & @crlf & _
			"")
	EndSwitch
WEnd

bu koddaki sorun sadece input1 islem yapmiyor yapiyoda input2 ye yazilan i yaziyo bide nedense hata veriyo ama hic bi sorun yok

Link to comment
Share on other sites

Gördüğüm hataları düzelttim... Kolay gelsin...

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

$Form1 = GUICreate("Form1", 358, 238, 276, 192)
$Input1 = GUICtrlCreateInput("", 100, 80, 129, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Input2 = GUICtrlCreateInput("", 100, 160, 129, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$start = GUICtrlCreateButton("Olustur", 125, 200, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Server Ismi", 20, 80, 80, 23)
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
$Label2 = GUICtrlCreateLabel("IP", 20, 160, 78, 18)
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $start
			$ISIM = GUICtrlRead($Input1)
			If $ISIM = "" Then
				MsgBox(16, "Serverinfo Olusturucu", "Server Ismini Yazmadiniz!")
				GUICtrlSetState($Input1, 256)
				ContinueCase
			EndIf
			$IPNO = GUICtrlRead($Input2)
			If $IPNO = "" Then
				MsgBox(16, "Serverinfo Olusturucu", "IP Numaranazini yazmadiniz!")
				GUICtrlSetState($Input2, 256)
				ContinueCase
			EndIf
			FileWrite("C:/extract/serverinfo.py", "import app" & @CRLF & _
					"import locale" & @CRLF & _
					"import debugInfo" & @CRLF & _
					"" & @CRLF & _
					"CHINA_PORT = 50000" & @CRLF & _
					"" & @CRLF & _
					"app.ServerName = None" & @CRLF & _
					"" & @CRLF & _
					'if locale.IsGERMANY() or (locale.IsEUROPE() and app.GetLocalePath() == "locale/tr"):' & @CRLF & _
					'	STATE_NONE = "Kapali"' & @CRLF & _
					'' & @CRLF & _
					'	STATE_DICT = {' & @CRLF & _
					'		0 : "....",' & @CRLF & _
					'		1 : "NORMAL",' & @CRLF & _
					'		2 : "BUSY",' & @CRLF & _
					'		3 : "FULL"' & @CRLF & _
					'	}' & @CRLF & _
					'' & @CRLF & _
					'	NurhakMt2_serverinfo_Generator = {' & @CRLF & _
					'		1:{"key":11,"name":"CH 1","ip":" & $IP & ","tcp_port":13000,"udp_port":13000,"state":STATE_NONE,},	' & @CRLF & _
					'	}' & @CRLF & _
					'' & @CRLF & _
					'	REGION_NAME_DICT = {' & @CRLF & _
					'		0 : "GERMANY",' & @CRLF & _
					'	}' & @CRLF & _
					'' & @CRLF & _
					'	REGION_AUTH_SERVER_DICT = {' & @CRLF & _
					'		0 : {' & @CRLF & _
					'			1 : { "ip":" & $IP & ", "port":11002, },' & @CRLF & _
					'		},' & @CRLF & _
					'	}' & @CRLF & _
					'' & @CRLF & _
					'	REGION_DICT = {' & @CRLF & _
					'		0 : {' & @CRLF & _
					'			1 : { "name" : ' & $ISIM & ', "channel" : NurhakMt2_serverinfo_Generator, },' & @CRLF & _
					'		},' & @CRLF & _
					"	}" & @CRLF & _
					"" & @CRLF & _
					"	MARKADDR_DICT = {" & @CRLF & _
					'		10 : { "ip" : " & $IP & ", "tcp_port" : 13000, "mark" : "10.tga", "symbol_path" : "10", },' & @CRLF & _
					"" & @CRLF & _
					"" & @CRLF & _
					"	}" & @CRLF & _
					"" & @CRLF & _
					'	TESTADDR = { "ip" : ' & $IPNO & ', "tcp_port" : 50000, "udp_port" : 50000, }' & @CRLF & _
					"")
			MsgBox(64, "Serverinfo Olusturucu", "İşlem tamamlandı!")
	EndSwitch
WEnd

Link to comment
Share on other sites

yardimin icin cok saol kardesim program sorunsuz calisiyo

son bi soru autoit te bir xml dosyasi veya baska bi dosyadaki yazilardan istedigimiz satirdaki yazilari degistire biliyormuz vede istedigimiz satirin altina bi satir daha olustura biliyomuyuz ??

Link to comment
Share on other sites

Xml dosyasını fazla tanımıyorum. Lakin büyük ihtimal her zaman text dosyası.

Kısaca bu işler için StringReplace kullanabilirsin.

Bir kaç örnek verim. Misal text dosyasındaki bir satırı değiştirmek istiyorsun. Hızlı bir function yazdım.

_BL_File_Replace_Line("dosya konumu","Aranacak yazı","Bulunursa değiştirilecek yazı")

MsgBox(0, "", _BL_File_Replace_Line("extract.xml","<Buildfile version='1.5'>" & @CRLF,"<Buildfile version='1.1'>" & @CRLF))
Func _BL_File_Replace_Line($Text_File,$Text_Searc,$Text_Replace)
	Local $File_Read = FileRead($Text_File,FileGetSize($Text_File))
	If @error Then Return SetError(1,0,0)
	$File_Read = StringReplace($File_Read,$Text_Searc,$Text_Replace)
	If @extended = 0 Then Return SetError(1,0,0)
	If StringInStr(FileGetAttrib($Text_File),"R") Then FileSetAttrib($Text_File,"-R")
	Local $FileOpen = FileOpen($Text_File, 2)
	If $FileOpen = -1 Then SetError(1,0,0)
	Local $File_Write = FileWrite($FileOpen, $File_Read)
	FileClose($FileOpen)
	If $File_Write = 0 Then SetError(1,0,0)
	Return 1
EndFunc

Bir satırı silmek için ise kısaca;

 _BL_File_Replace_Line("extract.xml","<Buildfile version='1.5'>" & @CRLF,"" & @CRLF)

Bir satırın altına yeni satır oluşturmak için ise;

 _BL_File_Replace_Line("extract.xml","<Buildfile version='1.5'>" & @CRLF,"<Buildfile version='1.5'>" & @CRLF & "Yeni satır" & @CRLF)

Tabi StringReplace arayıp buluduğu tüm yazıyı değiştirir. Eğer aynı yazıdan birden fazla var ise hepsini değiştirir...

Neyse umarım anlamıştırsın...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...