string needs to hold more characters help!!!

Hi i have a string which needs to hold more characters than it does at the moment. When the string holds more than allowed it throws an error. Is there a way i can get the string to hold any amount of characters, even say 30000 words of so? ← not that i need that many just want to be able to hol dmore.

if i spilt the above strings information then the error isnt displayed so it must be that!

What does the error say?

– Rob

the error is exactly what it was before:

it is definetly because the stuff that is copied from the oicture caption is to large,as when i take some words away it works.

Can i define how large a styring should be.

Oh and also rob, didnt need your thing in the end, i saved the caption as string not text as i was before.

I don’t think that you can control the limits of AppleScript. With that said, if I run the following, it does not produce an error, so I wonder if it’s AppleScript or IE that is causing the problem (your error indicates IE)

set f to "stop"
set counter to 0
repeat 30000 times
	set counter to counter + 1
	try
		set f to f & ("go" & return)
	on error e
		display dialog e & return & counter
	end try
end repeat

Tested on OS X 10.2.6. While it didn’t produce an error, it did make the fan of my PowerBook kick on after a couple of tests. :wink:

– Rob

hmm, it could be an IE thing.

Hmmmm, although when i do save the caption and display it in a dialog it doesnt save it all.

for example

the full string:

This is theful lstring nowt special reallybut its full

the caption variable:

This is theful lstring no

this sometimes happens and only when the error comes, so it led me to belive that there was a limit to the characters of possible bytes that it could store.

i know in java that ints can only hold a set number of bytes and if it goes over then an error occures, so this might be the same??

The captions that cause these errors are in the region of 100 - 300 words, nearer the top end.

I’m sure that there are storage limits but they should be well beyond 300 words. If you are attempting to force 100 - 300 words into a ‘display dialog’, the script will likely fail. I think the limit for a dialog is < 300 characters.

Update: The script might not fail but you will likely see truncation in the dialog.

– Rob

‘display dialog’ can only handle 255 characters and will truncate any longer strings before displaying them.

If you need to handle more characters than a string can handle, either use a list, multiple string objects, or use ‘unicode text’ rather than ‘string’. Unicode text has no significant length limitations.

Camelot, could you post a demo code using unicode text – I tried…

display dialog "A text block of more than 255 chars..." as unicode text

And it truncated the text at 255 characters in the dialog. tia

I think the unicode text part of Camelot’s reply applies to the amount of text held in a variable and not dialogs.

That’s correct - display dialog still has a 255 character limit, even if using unicode text - my original intent was to highlight the fact that unicode text doesn’t suffer from the same length limitation as strings.

(Thanks, Rob :slight_smile: )

i have been tryin ght eunicode text but still no luck.

The vcaption is:


Alain Colas, skipper of the giant four-masted schooner Club Mediterranee in the navigation room before the start of the 1976 Singlehanded Transatlantic Race. Milbay Docks Plymouth, England. Well ahead of his time, Colas had installed radar detectors to avoid possible collisions with ships on the 72 m long yacht. Quite strangely, the Royal Western YC Race Committee ordered Colas to disconnect the alarms. In October of the same year, the club decided of a new limied lenght, obliging the multihulls to have overhangs ! In reply, Frenchman Michel Etevenon decided to create the unlimited transatlantic Rum Race.

© Photo Denis Gliksman / Bluegreen Pictures
Alain Colas, skipper of the giant four-masted schooner Club Mediterranee in the navigation room before the start of the 1976 Singlehanded Transatlantic Race. Milbay Docks Plymouth, England. Well ahead of his time, Colas had installed radar detectors to avoid possible collisions with ships on the 72 m long yacht. Quite strangely, the Royal Western YC Race Committee ordered Colas to disconnect the alarms. In October of the same year, the club decided of a new limied lenght, obliging the multihulls to have overhangs ! In reply, Frenchman Michel Etevenon decided to create the unlimited transatlantic Rum Race.

© Photo Denis Gliksman / Bluegreen Pictures

I doubled it to see if it worked.

As can be seen it is rather large and i wondered whether you guys now seeing how long could think of a way to “trick” the program.

Can i creat my own datatypes and how much memory that type should have.

Cheers.

Just what is it you’re trying to do with this text?

It’s well within the length limits for an AppleScript text object, so if you’re generating an error, it must be related to what you’re trying to do with it and not the text itself.

what i am trying to do is get the caption from photoshop, as explained above i can do this, save that caption as avariable then in IE use the variable in a url query that will upload the information to a database.

admin.asp?caption=“&documentCaption&” ← for example

If i just copy and paste the caption from the file manually then upload it will store the caption. Which should be the same as the above, as the url that is sent stores the information the same way.

There is no need for me to encode the string with all the %20 and so on, as when i do this with a smaller caption it does it all and there are no problems.

I can’t really work out why it doesnt work. there is no reason why it shouldn’t work.

I am just trying to solve the problem and all i have come across is the length of the caption throughs the error.

I’d guess that there’s a limit to the length that a URL can be (in general or in IE).

– Rob

that might be but it seems strange that if i just cut and paste the same caption into the form field it works as iut should.

Oh well.

I still think this is an encoding issue. When you add text to a form field, the browser will encode it for you. When you add it through a URL, it is up to you to encode it.

Jon

hmmm, fai rpoint have thought about that but the resultant url after a successful dynamic upload is:


http://www.b...s.com/admin/libadd.asp?action=insert&image=104318%0D%0D&orientation=L&libraryno=A.Colas3/Keith.Taylor.jpg&description=June%201976.%20French%20singlehander%20Alain%20Colas%20showing%20one%20of%20the%20mainsail%20broken%20halyards%20after%20his%20arrival%20in%20Newport,%20R.I,%20USA.%20&format=O&photogid=11

as can be seem it does seem to encode it by itself.

this is baffaling. If i add an extra few words to the above capion then its spits the error.

What do you mean “successful dynamic upload”? If you mean you’ve added the caption to a field and submitted the form and this is the URL that is returned, then you’ve made my point that you need to encode the string if you are going straight to a URL as opposed to using a form field that will automatically encode the value for you.

Jon

sorry what i meant by dynamic was that the script does it all and is different every time.
so when i said successful dynamic upload i meant that the scipt did it all automatically. Just me being poncy i’m afraid and trying to sound clever. :oops:

I havent got a method in the script that encodes the URl it simply works with openURL.

So basically what i am saying is that the URL doesn’t get encoded my end, seems to get encoded in transit. I have never needed to encode the caption or the URL for that matter since doing this, and its been successfull for about 600 images. Just the few that have a large caption seem to cause conflicts

The output URL is after the upload.