Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 16, 2017 4:21 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: How to set a list of "quoted" items to a String Variable?
PostPosted: Sun Feb 10, 2013 9:46 pm 
Offline

Joined: Sat Dec 04, 2010 9:14 pm
Posts: 918
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
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Sun Feb 10, 2013 10:07 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
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
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Sun Feb 10, 2013 10:17 pm 
Offline

Joined: Sat Dec 04, 2010 9:14 pm
Posts: 918
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
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Sun Feb 10, 2013 11:13 pm 
Offline

Joined: Sat Dec 04, 2010 9:14 pm
Posts: 918
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
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Mon Feb 11, 2013 12:28 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
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
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Mon Feb 11, 2013 3:26 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
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
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Mon Feb 11, 2013 9:07 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
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
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Mon Feb 11, 2013 1:02 pm 
Offline

Joined: Sat Dec 04, 2010 9:14 pm
Posts: 918
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
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Mon Feb 11, 2013 1:11 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
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
 Profile  
Reply with quote  
 Post subject: Re: How to set a list of "quoted" items to a String Variabl
PostPosted: Mon Feb 11, 2013 3:28 pm 
Offline
User avatar

Joined: Tue Mar 04, 2008 1:20 pm
Posts: 95
[quote="tseyfarth"]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"

I have not tested this since I am not home, but try.

TableFieldNames = """comm_port0_enabled""", """comm_port1_enabled""", """comm_port2_enabled"""

When you put three quotes """ the compiler should know to keep one of the quotes. This should work with
all strings and take less instructions to execute.

_________________
iMac 2011, OSX Mountain Lion 10.8.1, Real Studio 2012r2.1


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group