Page 1 of 1

Another SelectedText Error

Posted: Mon Dec 01, 2014 4:18 am
by montymay
Today an error appeared in what had been a working feature. I have a scrolling, locked text field with lines of text, with the field's list behavior set to true. The first part of the field's script is:

Code: Select all

on mouseup
     put the selectedtext of me into vChapter
      . . . 
end mouseup
[code]

Formerly, the variable vChapter contained the text of the line selected. I could use it to go to to a particular card. Now I get an error. When I checked the contents of the variable, it contained only the first letter of the line, e.g., if the selected line was "Chapter 1. Introduction", the variable only contained "C". The same error is showing up in other fields. I downloaded a later version of LC, but same error. I could fix it by retyping the text in the field, but that will be a long task. Has anybody seen this behavior and has a suggestion to fix it?

Monty

Re: Another SelectedText Error

Posted: Mon Dec 01, 2014 5:25 am
by FourthWorld
What is the most recent engine version the script work with, and which engine version are you using?

Re: Another SelectedText Error

Posted: Mon Dec 01, 2014 7:22 am
by montymay
I am using different computers to work on the same stack (work, Windows 7; home, Windows 8.1): I sync the stack daily using an external hard drive. Your question suggests that the error is rooted in opening the stack in different LC versions, which is what I recently did. I opened it in LC 7 recently on my home computer, but removed LC 7 because PDFs would not open using the "launch document" command. I went back to an earlier version on my home computer, LC 6.7, I think. The error showed up on my work computer, LC 6.6.2. So, if that caused it, is there a fix? BTW, should stacks only be opened in the same version? If that causes systemic errors, was there a documented warning on doing what I did? Thanks for your help.

Monty

Re: Another SelectedText Error

Posted: Thu Dec 04, 2014 12:33 am
by bn
Hi Monty,

I recently had a problem with a table field created with a version of livecode < 7 that was opened and saved in LC 7 and reopened in a version < 7. Only the first tab showed.

When I issued

Code: Select all

set the htmlText of field "myField" to the htmlText of field "myField"
the rest of the text showed up again.

Admittedly this is not exactly what you are seeing but could you try this on a copy of your stack?

If that does not change anything: could you break out the field from your stack and put it into a new stack, just the field, if you create this stack with LC < 7 and open it in LC 7 and up and save it and then open it in e.g. 6.6.2 again: does the same happen?

I've tried to replicate your recipe but could not reproduce the problem. But there might be special characters in your field etc.

If you can isolate this and post it here one could try to replicate your problem and bug report it.

What you reported could be a problem with backward compatibility and it would be good to get to the bottom of this.

Kind regards
Bernd

Re: Another SelectedText Error

Posted: Sat Dec 06, 2014 12:24 am
by Lagi Pittas
Ive been "playing" for the best part of 4 hours to get this working

http://lessons.runrev.com/m/4071/l/7574 ... ab-buttons

on version 7.01 rc3

it gives an error
on the code as given below

on mouseUp
get the selectedText of me -- gets user's choice
go card it -- it is the name of the tab, which in turn will also be the name of the appropriate card
end mouseUp

the error is
group "TabControl": execution error at line 2 (selectedChunk: error in button or field expression), char 1

Any ideas? If it can be fixed I attach the stack

Thanks all

Re: Another SelectedText Error

Posted: Sat Dec 06, 2014 12:59 am
by bn
Hi Lagi,

the problem is that your code

Code: Select all

on mouseUp            
   get  the selectedText of me       -- Get user input                         
   go card it    -- it is the name of the tab, which in turn will also be the name of the appropriate card
end mouseUp
is in the script of group "tabControl"

remove the code there and put it into button "tab Menu"

Then it works.

When you put a mouseUp handler into the group script and the code says "get the selectedText of me" me refers to the group. And there is no selectedText in the group. Hence the error.

The appropriate place for the code is the tab menu button.

Also delete the on menupick handler you have there. You can do a the same in a menuPick handler but you have to look up how the "switch" structure works. The way it is now it would not work even if you update the card names.

Kind regards
Bernd

Re: Another SelectedText Error

Posted: Sat Dec 06, 2014 1:36 am
by Lagi Pittas
Thanks Berndt

Works a treat

It's not understanding what I have to do - it's selecting the correct object and following the terminology. I'm a dyed in the wool clipper/foxpro/visual foxpro/delphi (VB when I had to!!) programmer of nearly 30 years and I know where the brakes and steering wheel are on those platforms. Just need to acclimatize to a new system pretty sharpish.


Thanks again

Lagi

Re: Another SelectedText Error

Posted: Sat Dec 06, 2014 1:50 am
by bn
Lagi,

here are variants of a menuPick handler you could also use instead of the mouseUp handler:

Code: Select all

on menuPick pItemName
   go card pItemName
end menuPick
or

Code: Select all

on menuPick pItemName
   switch pItemName
      case "card 1"
         go card pItemName
         break
      case "card 2"
         go card pItemName
         break
      case "card 3"
         go card pItemName
         break
   end switch
end menuPick
although above version does not make much sense since you don't really have to switch since pItemName contains the card name where you want to go. No conditional needed. It is just to show the syntax. And "to acclimatize".

Kind regards
Bernd