FaridAgl Posted August 19, 2011 Share Posted August 19, 2011 Hi Guys, i hope my topic was not against rules! Func Server1() $Server1 = IniRead("Server.ini","Server","Server 1","4.2.2.4") $Server = "<?xml version=""1.0"" encoding=""UTF-8"" ?>" & @CRLF $Server &= "<servers>" & @CRLF $Server &= "<cur>Server 1</cur>" & @CRLF $Server &= "<server name=""Sever 1"" ip=" & $Server1 & " rate=""25""/>" & @CRLF $Server &= "</servers>" FileWrite("Server.xml", $Server) EndFuncIt's my code, as you can see i just read some variable from an existing .ini file using IniRead, and then i'm trying to make some kind of text generator (It's .xml).everything is ok but the only problem i have is in the final XML file " " is missed just where i write my variable.what it give:<server name="Serever 1" ip=4.2.2.4 rate="25"/>what i need:<server name="Server 1" ip="4.2.2.4" rate="25"/> http://faridaghili.ir Link to comment Share on other sites More sharing options...
FaridAgl Posted August 19, 2011 Author Share Posted August 19, 2011 (edited) Guys i think i found it, btw is there any better way? i did this and my code is working: Func Server1() $Server1 = IniRead("Server.ini","Server","Server 1","4.2.2.4") $Server = "<?xml version=""1.0"" encoding=""UTF-8"" ?>" & @CRLF $Server &= "<servers>" & @CRLF $Server &= "<cur>Server 1</cur>" & @CRLF $Server &= "<server name=""Sever 1"" ip=" & '"' & $Server1 & '"' & " rate=""25""/>" & @CRLF $Server &= "</servers>" FileWrite("Server.xml", $Server) EndFunc Edited August 19, 2011 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
smartee Posted August 19, 2011 Share Posted August 19, 2011 hi D4RKON3,Your topic is fine There is no need to mix single and double quotes to achieve this, you were so close to the solution! $Server &= "<server name=""Server 1"" ip=" & $Server1 & " rate=""25""/>" & @CRLFThe concatenation seems to have confused you, you successfully encapsulated the name by doubling up on the double quotes, but you faltered at the IP.Lets do it in steps, 1st with no variable IP:$Server &= "<server name=""Server 1"" ip=""0.0.0.0"" rate=""25""/>" & @CRLFThis should put the quotes around the IP as you wanted.Now if you wanted to put a variable between server and name you would do this right?$Server &= "<server " & $variable & "name=""Server 1"" ip=""0.0.0.0"" rate=""25""/>" & @CRLFSo to replace 0.0.0.0 with a variable, replace 0.0.0.0 with " & $variable & " right? This gives:$Server &= "<server name=""Server 1"" ip=""" & $Server1 & """ rate=""25""/>" & @CRLFSimple right?Hope this clears some things up -smartee Link to comment Share on other sites More sharing options...
bogQ Posted August 19, 2011 Share Posted August 19, 2011 (edited) $Server &= "<server name=""Server 1"" ip=""" & $Server1 & """ rate=""25""/>" & @CRLF $Server &= '<server name="Sever 1" ip="' & $Server1 & '" rate="25"/>' & @CRLF you mean ' instead of " or im missing the point? Edited August 19, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
smartee Posted August 19, 2011 Share Posted August 19, 2011 @bogQ, The op wanted the output to look like this:<server name="Server 1" ip="0.0.0.0" rate="25"/> To achieve that he tried this:$Server &= "<server name=""Server 1"" ip=" & $Server1 & " rate=""25""/>" & @CRLFinstead of this:$Server &= "<server name=""Server 1"" ip=""" & $Server1 & """ rate=""25""/>" & @CRLFthen maybe he was frustrated with double quotes so he did this:$Server &= "<server name=""Server 1"" ip=" & '"' & $Server1 & '"' & " rate=""25""/>" & @CRLF I was just showing how he could've done it using double quotes alone, as that seemed to be his original plan Link to comment Share on other sites More sharing options...
FaridAgl Posted August 19, 2011 Author Share Posted August 19, 2011 @bogQ, The op wanted the output to look like this:<server name="Server 1" ip="0.0.0.0" rate="25"/> To achieve that he tried this:$Server &= "<server name=""Server 1"" ip=" & $Server1 & " rate=""25""/>" & @CRLFinstead of this:$Server &= "<server name=""Server 1"" ip=""" & $Server1 & """ rate=""25""/>" & @CRLFthen maybe he was frustrated with double quotes so he did this:$Server &= "<server name=""Server 1"" ip=" & '"' & $Server1 & '"' & " rate=""25""/>" & @CRLF I was just showing how he could've done it using double quotes alone, as that seemed to be his original plan Exactly what i was searching for, tnx so much and it's done. http://faridaghili.ir Link to comment Share on other sites More sharing options...
bogQ Posted August 19, 2011 Share Posted August 19, 2011 (edited) ouh, ok i see, ty smartee , so i did miss the point after all ^^ but still think that $Server &= '<server name="Sever 1" ip="' & $Server1 & '" rate="25"/>' & @CRLF its easyer than $Server &= "<server name=""Server 1"" ip=""" & $Server1 & """ rate=""25""/>" & @CRLF newer the less the results are identical so what ever is easyer for him to understand is the best choice for him Edited August 19, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
H4CK3D Posted August 25, 2011 Share Posted August 25, 2011 (edited) Try: $Server &= "<server name=" & chr(34) & "Sever 1" & chr(34) & " ip=" & chr(34) & "" & $Server1 & " & chr(34) & "rate=" & chr(34) & "25" & chr(34) & "/>" & @CRLF If you want write " to file always use function chr(34) Edited August 25, 2011 by H4CK3D Link to comment Share on other sites More sharing options...
dinodod Posted August 25, 2011 Share Posted August 25, 2011 I found quad quotes ("""") work for me: $Server &= "<server name=""Sever 1"" ip=" & $Server1 & " rate=""25""/>" & @CRLF becomes: $Server &= "<server name=" & """" & "Sever 1" & """" & " ip=" & $Server1 & " rate=" & """" & "25" & """" & "/>" & @CRLF I'll have to look into the previous posts on how to wrap quotes around variables to see how that works. Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now