New topic: How to set a list of "quoted" items to a String Variable?
<http://forums.realsoftware.com/viewtopic.php?t=46900> Page 1 of 1 [ 9 posts ] Previous topic | Next topic Author Message tseyfarth Post subject: How to set a list of "quoted" items to a String Variable?Posted: Sun Feb 10, 2013 9:46 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 811 Hello all, How can I create a list of quoted items such as: TableFieldNames = "comm_port0_enabled", "comm_port1_enabled", "comm_port2_enabled" So when the variable TableFieldNames is used, the data presented is as: "comm_port0_enabled", "comm_port1_enabled", "comm_port2_enabled" Thanks All. Tim Top DaveS Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Sun Feb 10, 2013 10:07 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4533 Location: San Diego, CA try this TableFieldNames =replaceall( "'comm_port0_enabled','comm_port1_enabled','comm_port2_enabled'","'",chrb(34)) note SINGLE and DOUBLE quotes _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top tseyfarth Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Sun Feb 10, 2013 10:17 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 811 Thanks Dave! I almost feel guilty spending so much time trying to figure this out! Thanks for your response Dave! **Edit** How do you use the same strategy with a long list, and use the "_" at the end to continue the list on the next line? Tim Top tseyfarth Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Sun Feb 10, 2013 11:13 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 811 Unfortunately, that did not do the trick. What I am trying to do in the end is to replace this code: osqL.AddFieldS "comm_port0_enabled", "comm_port1_enabled", "comm_port2_enabled" with this code: TableFieldNames = "comm_port0_enabled", "comm_port1_enabled", "comm_port2_enabled" osqL.AddFieldS TableFieldNames The results are completely different between the two. The first example is parsed correctly into 3 different elements by osql.AddFieldS, the second is parsed as only 1 field element. Any ideas? Thanks, Tim Top DaveS Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Mon Feb 11, 2013 12:28 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4533 Location: San Diego, CA TableFieldNames =replaceall( _ "'comm_port0_enabled',"+_ "'comm_port1_enabled',"+_ "'comm_port2_enabled'", _ "'",chrb(34)) in your first example .. you are passing THREE distinct strings in your second example you are passing ONE string. Perhaps an ARRAY would be more appropriate? _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top timhare Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Mon Feb 11, 2013 3:26 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 12060 Location: Portland, OR USA Within a string literal, 2 double quotes represent a single literal double quote, so try TableFieldNames = """comm_port0_enabled"", ""comm_port1_enabled"", ""comm_port2_enabled""" Top DaveS Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Mon Feb 11, 2013 9:07 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4533 Location: San Diego, CA I believe the problem is NOT getting the string to LOOK correct, but getting it to BE correct It looks like AddFieldS requires 3 distinct strings... not ONE string that LOOKS like 3 strings _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top tseyfarth Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Mon Feb 11, 2013 1:02 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 811 Thanks for your repsonses. Dave, you are absolutely correct! Looks only work when they are correct! The double quotes did not work, although it was received by osql far better than before. However the SQL output was incorrect since it had quotes around each field name. Any ideas to best kill this problem? Thanks, Tim Top timhare Post subject: Re: How to set a list of "quoted" items to a String VariablPosted: Mon Feb 11, 2013 1:11 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 12060 Location: Portland, OR USA Ah, I see. You're going to have to use an array. dim TableFieldNames() as string .. TableFieldNames = array("comm_port0_enabled", "comm_port1_enabled", "comm_port2_enabled") or TableFieldNames.Append "comm_port0_enabled" TableFieldNames.Append "comm_port1_enabled" TableFieldNames.Append "comm_port2_enabled" or dim s as string = "comm_port0_enabled,comm_port1_enabled,comm_port2_enabled" TableFieldNames = split(s, ",") Then if there is a version of AddFields that accepts an array, you can pass it TableFieldNames. Otherwise, you'll have to iterate over TableFieldNames and call AddFields on each value. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 9 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
