Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 6:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Spaces in Variables. InternetPostData, PostWebData
PostPosted: August 9th, 2009, 1:41 am 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Hi

I'm at the end of a fairly big (and my first) Opus project. It uses lots of web interaction to communicate with our online database. As a last addition, I wanted to allow user comments to be posted and have just found out that all the spaces are removed from the variable as it is passed to my webpage.

e.g. 'This bit will not work' becomes 'Thisbitwillnotwork' somewhere between setting the variable and it arriving at my web scipt.

I initially was using the PostWebData action. I subsequently tried:

- InternetPostData script

- Adding quote marks around the variable i.e. = "'" + comment + "'"

- toString()

Up against a very close deadline, I floundered for any solution, so tried replacing all spaces with underscore using javascript replace function (thought I'd try, but it wasn't going to happen).


Finally decided to write a script to search through the string and replace all spaces, but got stuck with 'SetSelection' ("Function Not Found : Check spelling and capitalisation"). Tried restart, reinstall on vista, reinstall on XP to no avail.

The thing is, I don't want to spend hours working out why 'SetSelection' isn't working (even when copying the simple script out of the help files into a new button) when there may be an easy solution.

Any help would really be appreciated.

FornowI'llhavetodecipheranymessagesthatpeoplesend.

Thanks
Dan


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 28th, 2009, 9:17 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Dan1, ...is this still an issue for you?

** Bump **

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: August 30th, 2009, 5:44 am 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
From tech support below. This solved the problem, but it was definitely an issue using the action and the script method.

Cheers
Dan


..........................................
This is not a bug but user error. The data needs to be in the correct CGI encoded format for posting, which is something Opus does automatically when using the web post action, but not when using the web post script because it's more powerful for developers.

The simple answer is to replace the spaces with + symbols, with script something like this:

var data = "This is some text with spaces in it.";

// change spaces to +'s
var array = data.split(" ");
data="";
for(var i=0;i<array.length-1;i++)
{
data += array[i];
data += "+"
}
data+=array[i]

outdata =
InternetPostData(http://www.example.com/xyz.php,
"data=" + data)



.................


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 30th, 2009, 6:46 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
The data needs to be in the correct CGI encoded format for posting, which is something Opus does automatically when using the web post action, but not when using the web post script

Good to know.

I wonder if there are better ways of handling that (than '+' signs). Maybe converting spaces to charcodes. Maybe putting the string value in extra quotemarks... e.g. '"This is some text with spaces in it."' ????

BTW, I had to do some similar 'extra handling' to not lose tabs and paragraph formatting for data going into SQLite DB (on local client system). I forget specifics.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: August 30th, 2009, 8:43 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Ouch!

Okay, it's early Sunday morning and pre-caffeine, but I think you want this:

myString = "This is some text with spaces in it.".split(" ").join("+")

Debug.trace(myString)

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 1st, 2009, 8:39 pm 
Offline
User avatar

Joined: October 25th, 2004, 10:33 am
Posts: 257
Location: UK
Opus: Pro 8
OS: Windows 7 Professional x64
System: Dell XPS15 i7x4 2.1Ghz 6GB 128GB SSD
mackavi wrote:
myString = "This is some text with spaces in it.".split(" ").join("+")


That'd work too. :wink:


For this message Dave Emberton has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 14 guests


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
You cannot post attachments in this forum

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