cardsize,find,field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

cardsize,find,field

Post by robm80 » Sun May 18, 2014 8:38 am

3 questions:

1. is it possible to change the size of 1 card without resizing the whole stack.
2. with find I see a rectangle around the chosen word. How when there are more identical words and I want them all. No such as "find again"?
With the that word I want to do someting with it, f.i. asking position, linenumber, position of first and last char; How?
3. In a scrolling list field I want by pressing a key, the first line beginning with that char scrolls up. Possible?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: cardsize,find,field

Post by jmburnod » Sun May 18, 2014 10:51 am

Hi Rob
1. is it possible to change the size of 1 card without resizing the whole stack.
As far I know NO
2. with find I see a rectangle around the chosen word. How when there are more identical words and I want them all. No such as "find again"?
With the that word I want to do someting with it, f.i. asking position, linenumber, position of first and last char; How?
Yes. There is many ways to do that. I' cooking one and I'm coming back
3. In a scrolling list field I want by pressing a key, the first line beginning with that char scrolls up. Possible?
Yes. Here is one way to do it.

-- script cd

Code: Select all

on keyup pKey
   put allFirstLetters(myField) into tallFirstLetters
   put pKey & "," into tSearch
   put lineoffset(tSearch,tallFirstLetters) into tNumLine
   get fDeNumToScroll(myField,tNumLine)
  set the hilitedlines of fld "myField" to item 2 of line  tNumLine of tallFirstLetters
   set the scroll of fld "myField" to fDeNumToScroll(myField,tNumLine)
end keyup

--•• return a list of each first letter with the number of the foundline
function allFirstLetters pNameField
   put empty into rallFirstLetters
   put fld pNameField into tContentFld
   put 0 into tCount
   repeat for each line tLine in tContentFld
      add 1 to tCount
      if char 1 of tLine is in rallFirstLetters then next repeat
      put char 1 of tLine & "," & tCount & cr after rallFirstLetters
   end repeat
   delete char -1 of rallFirstLetters
   return rallFirstLetters
end allFirstLetters

--•• return the destination scrollV of the fld
 function fDeNumToScroll pNameField,pNum
  put the  effective textHeight of fld pNameField into tSec
   put (pNum-1)* tSec into tScroll
   return tScroll
end fDeNumToScroll
Best regards
Jean-Marc
https://alternatic.ch

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: cardsize,find,field

Post by robm80 » Sun May 18, 2014 11:18 am

Hello Jean-Marc
Rather complicated, but I'll study on it.
Thanks a lot
Rob

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cardsize,find,field

Post by Klaus » Sun May 18, 2014 11:47 am

Hi Rob,
robm80 wrote:Rather complicated...
well, you didn't ask for the BEEP command! :D


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: cardsize,find,field

Post by jmburnod » Sun May 18, 2014 12:19 pm

Hi Rob,
In fact it doesn't work as expectd for me 8)
Testing and cooking again is the way :D
The same for you second question

Code: Select all

-- Cd script
--Search  all word contain a string in field "myField" 
on debSearchString
   ask "Search"
   if it = empty then exit debSearchString
   put it into pString
   get getLinesWithString(pString, "myField")
   put  it into fld "fResult"
   setStyleFoundLine it,"myField"
end debSearchString

on setStyleFoundLine pFoundLine,pNameField
   set the textstyle of line 1 to -1 of fld pNameField to plain
   repeat for each line tLine in pFoundLine
      set the textstyle of line (item 2 of tLine) of fld pNameField to box
   end repeat
end setStyleFoundLine

function getLinesWithString pString,pNameField -- return a list  FoundWord,FoundLine
   put empty into rgetLinesWithString
   put fld pNameField into stringToSearch
   put 0 into tCount
   repeat for each word tWord in stringToSearch
      add 1 to tCount
      if pString is in tWord then
         put tWord & ","  & tCount & cr after rgetLinesWithString
      end if
   end repeat
   delete char -1 of rgetLinesWithString
   return rgetLinesWithString
end getLinesWithString
Best
Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cardsize,find,field

Post by Klaus » Sun May 18, 2014 2:09 pm

Dag Rob,
robm80 wrote:1. is it possible to change the size of 1 card without resizing the whole stack.
no, the STACK sizes defines the CARD size, not vice versa!
Of course you can set the stack size to whatever you want "on opencard" and "reset" it again "on closecard"!
robm80 wrote:2. with find I see a rectangle around the chosen word. How when there are more identical words and I want them all. No such as "find again"?
With the that word I want to do someting with it, f.i. asking position, linenumber, position of first and last char; How?
Let's see, what Jean-Marc comes up with for dinner :D
robm80 wrote:3. In a scrolling list field I want by pressing a key, the first line beginning with that char scrolls up. Possible?
Put this into the list fields script:

Code: Select all

on keyUp tKey
  put lineOffset(return & tKey, the text of me) into tLineOffset
  set the scroll of me to tLineOffset * the effective textHeight of me
end keyUp
Best

Klaus

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: cardsize,find,field

Post by robm80 » Mon May 19, 2014 4:54 am

Gutenacht Klaus
on keyUp tKey
put lineOffset(return & tKey, the text of me) into tLineOffset
set the scroll of me to tLineOffset * the effective textHeight of me
end keyUp
1. hese 2 lines do exactly what I wanted, but I don't understand the script and how it is working: I know what lineoffset does, but "return & tKey, the text of me) " is to much for me. I suppose thst tKey is a variable,
but why it is called once? It gives a number between to keys that has some thing to do with the scroll. Why to multipky it with the the effective textHeight of me

2.I want to follow my scripts with the debugger and I read what was in the tutorials. Here is a discepancy between LC's message box and the mine, and pressing an intelligents button does nothing. Have a look:
sshot-3.jpg
LC's
and
sshot-4.jpg
mine

I see that no sufficient pictures are accepted, so read my search story under "search".
Thanks

Post Reply