Is the word "infinity" a problem for LiveCode?

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
Maxiogee
Posts: 38
Joined: Thu May 05, 2011 5:45 pm

Is the word "infinity" a problem for LiveCode?

Post by Maxiogee » Tue Dec 09, 2014 9:27 pm

I have a stack which records thew words used in a word game I have been playing.
I wished to tally the frequency of occurrence of the words (there was a lot of repetition across levels).

The stack contained 26 cards, one for each letter of the alphabet, and each card had 8 fields - an identifying field and one for words of lengths from 2 to 8 letters.

Code: Select all

on mouseUp
   repeat with a = 1 to 26
      go to card a
      repeat with b = 2 to 8
         sort lines of field b ascending
         repeat with c = number of lines in field b down to 1
            put line c of field b into wurd
            put 1 into count
            if line (c-1) of field b = wurd then
               repeat with d = (c-1) down to 1
                  if line d of field b = wurd then
                     add 1 to count
                     delete line d of field b
                     put c-1 into c
                  end if
               end repeat
            end if
            put wurd && count into line c of field b
         end repeat
      end repeat
   end repeat
end mouseUp
The following script worked fine for all words with the exception of the word "infinity"

The eight-letter word field on the 'I' card contains six lines. Each one holds the word "infinity"
The field, after running that script contains six lines, each one reading "infinity 1"
If I replace the word infinity in the source data with, say "innocent", the script functions perfectly with just one line in that field, which reads "innocent 6".

Is "infinity" an issue when making a comparision?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Is the word "infinity" a problem for LiveCode?

Post by dunbarx » Tue Dec 09, 2014 10:00 pm

Hi.

It is not a native word. Does the machine see something we don't? Has it become self-aware?

Craig

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Is the word "infinity" a problem for LiveCode?

Post by magice » Wed Dec 10, 2014 5:34 pm

I am curious why you have "go to card a" within the repeat loop. It seems unnecessary to repeat a navigation command 26 times. It looks like you are going to that card simply to use the fields of that card specifically. Instead reference the card number with the field references E.G. "field b of cd a"

Maxiogee
Posts: 38
Joined: Thu May 05, 2011 5:45 pm

Re: Is the word "infinity" a problem for LiveCode?

Post by Maxiogee » Wed Dec 10, 2014 7:43 pm

magice wrote:I am curious why you have "go to card a" within the repeat loop.
It gave me something to look at while the job was in progress.
I hate looking at a locked screen.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Is the word "infinity" a problem for LiveCode?

Post by magice » Wed Dec 10, 2014 7:47 pm

Maxiogee wrote: It gave me something to look at while the job was in progress.
I hate looking at a locked screen.
LOL That is the perfect answer....Carry on sir.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Is the word "infinity" a problem for LiveCode?

Post by jacque » Thu Dec 11, 2014 8:47 pm

Here's a quick way to do it, which avoids navigating cards and shortens the algorithm by using an array:

Code: Select all

on mouseUp
  repeat with a = 1 to 26
    repeat with b = 2 to 8
      put fld b of cd a into tText
      put empty into tArray
      repeat for each word w in tText
        add 1 to tArray[w]
      end repeat
      combine tArray by cr and space
      -- sort here if you want the text ordered
      put tArray into fld b of cd a
    end repeat
  end repeat
end mouseUp
It should be very fast, it's actually an adaption of a handler from MetaCard to measure speed. The array will not be in the original order after it is combined, so you may want to sort the text before placing it into the field.

By the way, I had no problem with the word "infinity".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply