Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 6:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ReplaceSelection
PostPosted: December 29th, 2004, 11:02 am 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
Hi,

I have a problem with using replaceselection in a function. Everything works fine ( I have checked by substituting the lettervariable and letter[loop]) until I want to update a particular text object using the "lettervariable" as seen below.

I have used something similar before but, as is always the case, I can't now find it!
============================================

function CheckLetter(LetterPressed)
{
for (Loop = 1;Loop < letter.length +1;Loop ++)
{
if (LetterPressed == letter[Loop])
{
var lettervariable = "letter" + Loop
eval(lettervariable)

CheckLetter1 = lettervariable // checks variable works

lettervariable.SetSelection(0,-1)
lettervariable.ReplaceSelection(letter[Loop])

}
}
}

============================================

The function should iterate through to check to see if a particular letter (letterpressed) is found within the characters in a word (previously read into an array).

There is probably something obvious that too much Christmas spirit has made me overlook, so any help would be appreciated.

Regards

Clive Cartmel


For this message Clive Cartmel has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Replaceselection problem
PostPosted: January 2nd, 2005, 9:37 pm 
Offline

Joined: November 3rd, 2004, 4:48 pm
Posts: 20
Location: Sheffield, UK
Clive

I guessing here, but has Loop been declared? In the For loop, if Loop has not been declared then ReplaceSelection(letter[Loop]) will not have anything to replace. If this is the problem then try:

for (var Loop = 1;Loop < letter.length +1;Loop ++)
etc.

Hope this helps.

Paul Conway


For this message amethyst has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: January 5th, 2005, 7:01 pm 
Offline

Joined: November 3rd, 2004, 6:44 pm
Posts: 59
Location: Ipswich, UK
Paul,

Thanks for your reply

I worked it out for myself in the end as the help file was a little ambiguous!

I had put:

lettervariable.SetSelection(0,-1)
lettervariable.ReplaceSelection(letter[Loop])

not realising that a more specific use of "" was needed with the eval statement.

It finally looked something lik:

eval("letter"+offset+ ".SetSelection(0,-1)")
eval("letter"+offset+ ".ReplaceSelection(letter[Loop])")

By the way, the loop does not have to be declared in the IF statement - I had been through all those possibilities too!

Thanks for you interest.

Clive Cartmel


For this message Clive Cartmel has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 10 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