Identifying occurences of specified text in one substack and report to another substack

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5114
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by jacque » Mon Apr 15, 2019 4:55 pm

I believe that was Mark Weider, who's very good at that sort of thing. His puns are enough to make you go "ewww" and he comes up with some hilarious replies on the list.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 3816
Joined: Sat Feb 25, 2017 10:45 pm

Re: Identifying occurences of specified text in one substack and report to another substack

Post by bogs » Tue Apr 16, 2019 12:01 pm

It could very well be, I haven't had to go back to the old lists very much in the last 4 or so months, but I remember a number of lively discussions that went on there and in other forums.
Image

kresten
Posts: 134
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by kresten » Thu Apr 25, 2019 9:33 am

Hello again.

I have , without success, tried and tried repairing the scipting of the basic parsing handler of my freeware diary program,

It strucked me, that the optimal solution would be if I could lure /tempt / entice one of you to recieve and inspect a copy of the program as is.
The uncompressed size of the program is 2,4 MB
If none of you are interested , you might suggest an alternative stratejy.
For further information on the context: www.phenomenalog.dk.
for personal contact: kresten,bjerg@psy.ku.dk

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 97
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by PBH » Sat Apr 27, 2019 6:01 pm

This was pretty simple to debug, I just recreated a small stack with all the objects listed in your sample and run it, it returned the error: button "Button_A": execution error at line 31 (Chunk: no such object), char 1

Note button "Button_A" was just what I called the button that held the script.

The error appeared because of the line "new card", you ask to open field "searchings" straight after creating a new card, so LC would make that the active card and the field "searchings" doesn't exist on that card, hence the error! Comment out that line and the error goes away and the script completed as expected.

The errors show at the bottom of the IDE Script Editor, see https://www.dropbox.com/s/w12q3m6iv7830 ... t.png?dl=0.

I have cleaned up your script a little noting previous comments, and to make it easier to read and compile, you may find this article by Richard Gaskin useful for future reference:
http://www.fourthworld.com/embassy/arti ... style.html

This worked for me, hope it helps.

Code: Select all

on phenoparse
   global gPhenodate, gCue, gStart, gHitcard
   
   ask "Which word shall be searched?"
   if it is empty then
      exit phenoparse
   else
      put it into gCue
   end if
   
   ask "How many lines before ?" with "0"
   if it is cancel then
      exit phenoparse
   end if
   put it into tAvant
   
   ask "How many lines after ?" with "0"
   if it is cancel then
      exit phenoparse
   end if
   put it into tApres
   
   open stack "Parsings"
   --new card -- <-- THIS LINE CAUSES THE ERROR!
   open field "searchings"
   put "Parsed for" && gCue && gPhenodate after field "searchings"of stack "Parsings"
   close stack "Parsings"
   
   go first card of stack "Phenomenalog"
   find string gCue in field "TextField"
   if the result is "not found" then
      answer "Cannot find this word"
      exit phenoparse
   else
      put short name of this card && the foundchunk into gStart
      put short name of this card into gHitcard
      put "<p>" & gStart & gHitcard &"</p>" into field "occurrences" of last card of stack "Parsings"
      put "<p>" & short name of this card & "</p>" into field "occurrences" of last card of stack "Parsings"
      -- put the htmltext of line (word 2 of the foundline) -tAvant to (word 2 of the foundline) + tApres of field "Textfield" after field “occurrences” of stack pParsings 
   end if
   
   repeat
      set cursor to busy
      find string gCue in field "TextField"
      if short name of this card && the foundchunk is gStart then
         exit repeat
      end if
      if short name of this card is not gHitcard then
         put short name of this card into gHitcard
         put "<p> ----------------------</p>" after field "occurrences" of stack "Parsings"
         put "<p>" & short name of this card & "</p>" after field "occurrences" of stack "Parsings"
      end if
      put the htmltext of line (word 2 of the foundline) -tAvant to (word 2 of the foundline) + tApres of field "Textfield" after field "occurrences" of stack "Parsings"
   end repeat
   
   go last card
   put return & gPhenodate && the time && "Parsed:" && gCue after field "TextField"
   
   show stack "Parsings"
end phenoparse
Paul :)

kresten
Posts: 134
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by kresten » Tue Apr 30, 2019 3:31 pm

Dear Paul

I really appreciate your performing the experiment. Just deleting the new card line put the results of all parsings in in one card, but by introducing the new card line in the beginning of the script it functions in producing new cards with searching and occurrences . However the occurrences listed are described in a way less satisfactory: e.g. : <p><font size="14">15:28 &#9;principia</font></p><p> ----------------------</p><p>card id 11565</p><p><font size="14">15:27 &#9;principia</font></p>.

I am unable to understand how this can be repaired.
Can you be tempted to download the full application and inspect the context in which the parsings shall operate ?

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 97
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by PBH » Wed May 01, 2019 12:39 am

I have downloaded the app, but it's way too complex for me to diagnose.

My test was a little too simple I believe, now I realise that you stack Parsings holds a background group, which I didn’t realise at first, so the new card line does work OK.

Have you renamed the variable "start" as was suggested? Start is a LC command so this could introduce unpredictability.

Also, I don't really understand what you are expecting to be repaired, can you describe the error that occurs?

Paul

kresten
Posts: 134
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by kresten » Thu May 09, 2019 6:24 pm

Dear Paul

I hope you will excuse me for giving you the impression that the version 21.1 I have brought up in this forum could be downloadet from the phenomenalog site , I am sorry , but what you have downloadet must be an installer for the standalone of the 19.7.5 version (and the 12 glyph-fonts).

As to the details in the working of the present parsing handler
I note, that reference to the operation in the daycard textfield is indicated precisely as wished for:

15:29 Parsed : principia

A new card is correctly produced in the parsings stack, and its searchings field correctly identifies “parsed for principia”
But references in the occurrences field of the parsings stack is strangely –and inconsistently – disfigured:
“<p>190311</p><p><font size="14">15:28 &#9;principia</font></p><p> ----------------------</p><p>card id 11565</p><p><font size="14">15:27 &#9;principia</font></p>

The format of this should have been
190311
15:28 _ _principia
----------------------
190430
15:27 _ _principia

Where do I go from here ?

I cannot but hope, that you may be tempted to have a look in the present version ( as somehow deliverable to you pr dropbox)
Dear Paul

I hope you will excuse me for giving you the impression that the version 21.1 I have brought up in this forum could be downloadet from the phenomenalog site , I am sorry , but what you have downloadet must be an installer for the standalone of the 19.7.5 version (and the 12 glyph-fonts).

As to the details in the working of the present parsing handler
I note, that reference to the operation in the daycard textfield is indicated precisely as wished for:

15:29 Parsed : principia

A new card is correctly produced in the parsings stack, and its searchings field correctly identifies “parsed for principia” But references in the occurrences field of the parsings stack is strangely –and inconsistently – disfigured:
“<p>190311</p><p><font size="14">15:28 &#9;principia</font></p><p> ----------------------</p><p>card id 11565</p><p><font size="14">15:27 &#9;principia</font></p>

The format of this should have been
190311
15:28 _ _principia
----------------------
190430
15:27 _ _principia

Where do I go from here ?

I cannot but hope, that you may be tempted to have a look in the present version ( as somehow deliverable to you pr dropbox)
Dear Paul

I hope you will excuse me for giving you the impression that the version 21.1 I have brought up in this forum could be downloadet from the phenomenalog site , I am sorry , but what you have downloadet must be an installer for the standalone of the 19.7.5 version (and the 12 glyph-fonts).

As to the details in the working of the present parsing handler
I note, that reference to the operation in the daycard textfield is indicated precisely as wished for:

15:29 Parsed : principia

A new card is correctly produced in the parsings stack, and its searchings field correctly identifies “parsed for principia” But references in the occurrences field of the parsings stack is strangely –and inconsistently – disfigured:
“<p>190311</p><p><font size="14">15:28 &#9;principia</font></p><p> ----------------------</p><p>card id 11565</p><p><font size="14">15:27 &#9;principia</font></p>

The format of this should have been
190311
15:28 _ _principia
----------------------
190430
15:27 _ _principia

Where do I go from here ?

I cannot but hope, that you may be tempted to have a look in the present version ( as somehow deliverable to you pr dropbox)

best regards from Kresten

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 97
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by PBH » Sat May 11, 2019 7:53 pm

Sorry, but I'm really busy for a few days, we're fighting a forrest fire close by right now, I'm just on a short break, but I will take another look when we've finished.

Just a quick thought in the meantime I noticed that the reference to "&#9;" is an ascii code for TAB, I wonder if that's causing some confusion in your code, maybe something to do with the double underscores and your glyph font not being fully compatible with the limited HTML capability of LC?

Paul

kresten
Posts: 134
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by kresten » Fri May 24, 2019 7:31 am

Dear Paul
I have also been busy with other matters, including repairs on the script of the full diary-application, which I am looking forward , hopefully, to share with you. I can see that this may take , perhaps, yet another couple of weeks
best regards
from Kresten

kresten
Posts: 134
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Identifying occurences of specified text in one substack and report to another substack

Post by kresten » Wed Jun 12, 2019 4:14 pm

Dear Paul

I am impressed, that you manage to help your local firedepartment-. I only know about forest fires from tv. How terrible and overpowering they must be. I dont wish you to waste a minute from those efforts.
Meanwhile I have reflected about the possible collaboration we could have.
In a way the topic about parsing for appearences of a text or a "glyph" is just an ultimate functionality in a application, a virtual personal vehicle, designed to allow the user to furnish and organize as best fitted to personal relevances.
Therefore the best way to start, I think, would be if you could try to use it, drive it ,on a daily basis, inhabit it, at least for a week or more, postponing the issue about parsing until you have accumulated a series of daycards.
This implies also that you should install the 12 glyph-fonts.
I am curious to hear what you think about this.
Best regards from
Kresten

Post Reply

Return to “Talking LiveCode”