Options in Search Project

Using SuperCard and the Runtime Editor... working with windows, backgrounds, cards and menus.

Options in Search Project

Postby DaveFrancis » Wed Apr 18, 2018 1:11 pm

Just a minor inconvenience: In Options of the Search Project, I have the Contents and Object Names unchecked, but whenever I do a search the results always include the contents of fields and names of objects.

Cheers, Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby Scott » Wed Apr 18, 2018 10:08 pm

I'm not seeing this here.
:?
User avatar
Scott
Site Admin
 
Posts: 1248
Joined: Sat Jul 05, 2008 1:37 pm
Location: Northern Sierra Nevada

Re: Options in Search Project

Postby DaveFrancis » Thu Apr 19, 2018 1:51 pm

Thanks Scott. I can't imagine any reason why you guys would change the Search Project, so I assume you haven't touched it.

I thought maybe my copy had got corrupted (unlikely I suppose), but I've had a peek at the script in the Search button, and on the face of it it looks quite straightforward: if a particular button is hilited put a 1 in the relative global, if the global has a 1 in it run the relative search using checkit.

There's lots more to the script than that of course, but it would take me hours to figure out every detail. Knowing just where to look might help. Any suggestions? :)

Cheers, Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby Scott » Thu Apr 19, 2018 2:50 pm

What version are you running?
User avatar
Scott
Site Admin
 
Posts: 1248
Joined: Sat Jul 05, 2008 1:37 pm
Location: Northern Sierra Nevada

Re: Options in Search Project

Postby DaveFrancis » Thu Apr 19, 2018 6:12 pm

Oh.. Ah um.. (blushing furiously).. now that I check I can see that version 4.8 is in fact quite different to v 4.7. Having assumed you wouldn't have changed anything, I've been using the old one - only because I made the window bigger and the textSize bigger for more convenience.

So I guess you must have found a few bugs in the old one after all. Sorry Scott, I'll start using v 4.8 right away. Silly old fool should have checked the version number as a matter of course. :oops:

Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby DaveFrancis » Thu May 10, 2018 9:16 pm

Well, the new Search Project is lightning fast I must say. But it's still including Contents in the search in spite of the Contents being unchecked in the Options list.

There's another problem though. When searching just now it found a userProp containing the search string, but when I double-clicked the line to edit or check the userProp, I got "SuperTalk Error No. 2. Can't understand arguments".

I haven't tried to trace the bogy as I'm busy with stuff of my own I'm working on.

Cheers, Dave,
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby DaveFrancis » Fri May 11, 2018 2:06 pm

Okay, I get it now. The Options window must be opened every time I use the Search, otherwise the project "forgets" what the Options setting are, even though the actual button settings haven't changed.

Trying to access a userProp from the Results field still gets an error though.

Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby codegreen » Wed May 16, 2018 6:02 am

DaveFrancis wrote:Okay, I get it now. The Options window must be opened every time I use the Search, otherwise the project "forgets" what the Options setting are, even though the actual button settings haven't changed.

AFAIK this behavior is unchanged from 4.7x.

DaveFrancis wrote:Trying to access a userProp from the Results field still gets an error though.

Not seeing that here. What's the name of your userprop?

-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Re: Options in Search Project

Postby DaveFrancis » Wed May 16, 2018 1:27 pm

Most of them start with a u as in uDataCore, but the error is happening when trying to open any one of them from within the search results field.

Just to clarify; searching for the name of a userProp doesn't get any result at all, which is fine with me. But searching any text string that happens to be in the contents of a userProp brings up a 'Property' in the search results window. Double clicking that 'Property' line gets the error message.

Oh, and the Search Project seems to be remembering my Options settings now, which I'm pleased about. ;)

Cheers, Dave.
Attachments
Screen Shot 1.jpg
Screen Shot 1.jpg (44.2 KiB) Viewed 78 times
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby codegreen » Wed May 16, 2018 6:41 pm

And what's the line of script that's throwing the error?

Thanks,
-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Re: Options in Search Project

Postby DaveFrancis » Thu May 17, 2018 12:04 pm

[And what's the line of script that's throwing the error?]

Apparently a string of local variables within the 'switch tReferenceType' of the 'mouseUp' handler in cd btn 'Edit Property'

Would you believe it, I opened my pet project just now to get an answer for you and found that the Search project worked okay, finding and letting me open userProps without a problem. Then I realised I hadn't re-set the Options, so I opened that and closed it again (the settings were already in there), then when I tried another search I got the error again.

So I guess, somehow the Options settings must be putting the cat among the pigeons.

Cheers, Dave.
Attachments
Screen Shot 1.jpg
Screen Shot 1.jpg (42.15 KiB) Viewed 60 times
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby codegreen » Thu May 17, 2018 12:59 pm

Okay I'm still not able to reproduce this here.

Could you please open the msg box and type "trace" & return, then try editing the uprop again?

Click "Trace" in the error dialog, expand the Tracer window so everything is visible, and post a screenshot of it.

Thanks!
-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Re: Options in Search Project

Postby DaveFrancis » Thu May 17, 2018 7:04 pm

Okay, here we go.

I'll need to split the screenshot into 2 to post it.

Dave.
Attachments
Screen shot 1.jpg
Screen shot 1.jpg (45.92 KiB) Viewed 51 times
Screen shot 2.jpg
Screen shot 2.jpg (40.77 KiB) Viewed 51 times
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby codegreen » Fri May 18, 2018 6:21 am

Hi Dave,

Okay that was helpful.

Would you do me a favor and try commenting out that offending line in the script of the Edit Property button and replacing it with this one:

Code: Select all
local tTargetObject = iif(tTargetIsNotTheProject, tReferenceRoot && "of project tProjectToSearch", tReferenceRoot && "tProjectToSearch"), tPropertyData = the tPropertyName of iif(tTargetIsNotTheProject, tTargetObject, value(tTargetObject))

Then let me know if that fixes the problem at your end.

Thanks!
-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Re: Options in Search Project

Postby DaveFrancis » Fri May 18, 2018 12:07 pm

Yay.. That seems to have fixed it Mark, thanks for your patience and your help !

Now, if I might just push my luck a little :)

I'm averse to tinkering with your SC scripts, or delving into them very deeply, but can you suggest a simple way I might make my preferred Search Options become the Default?

Thanks again, Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby codegreen » Fri May 18, 2018 1:31 pm

Hi Dave,

OK keep in mind I didn't actually write this thing (I just cleaned it up a bit) so take this with a grain of salt...

First you'd need to patch the openWindow handler of the main search window as follows:

Code: Select all
on openWindow
 lock screen
 set the uTextArrowsonOpen of this proj to the textArrows
 put "" into cd fld "foundSearch"
 put "" into cd fld "Search String"
 put "" into cd fld "Replace String"
 set the textStyle of cd fld "Search Options" to plain
 put merge("Check:  [[objectsToCheck()&cr]]Scope:  [[whatToCheck()]]") into cd fld "Search Options"
 -- put "Check:  Contents, Names, Scripts, User Properties"&cr&"Scope:  All Objects" into cd fld "Search Options"
 -- set the hilite of btn id 115 of wd id 245  to true
 -- set the hilite of btn id 114 of wd id 245 to true
 -- set the hilite of btn id 116 of wd id 245 to true
 -- set the hilite of btn id 3816 of wd id 245 to true
 set the textStyle of word 1 of line 1 of cd fld "Search Options" to bold
 set the textStyle of word 1 of line 2 of cd fld "Search Options" to bold
 set currentValue of cd btn id 3811 to 1
 set the lockText of cd fld "Replace String" to true
 set the fillFore of cd fld "Replace String" to 247
 -- set the storedChecks of wd id 245 to ""
 set name of cd btn id 104 to (the uLoc_SearchBtn of this wd)
 disable cd btn id 104
 disable cd btn id 1446
 set the name of cd btn id 1445 to (the uLoc_CancelBtn of this wd)
 disable cd btn id 112 --"Print Results"
 disable cd btn id 3806 --"Save Results..."
 set the lockText of cd fld "ShowStuff" to true
 hide cd fld "ShowStuff"
 hide cd fld "ObjDesc"
 set the textArrows to true
 click at the loc of cd fld "Search String"
 unlock screen
end openWindow

Then you'd need to add these two functions to the project script:

Code: Select all
function whatToCheck
  enum firstWhat = 16, lastWhat = 19
  local theResult = ""
  repeat with x = firstWhat to lastWhat
    if (the hilite of cd btn x of wd id 245) then put short name of cd btn x of wd id 245 & ", " after theResult
  end repeat
  delete last char of theResult
  delete last char of theResult
  return theResult
end whatToCheck

function objectsToCheck
  enum firstCheck = 4, firstWhat = 16
  local theResult = "", showAll = true, abbrList = "Proj,Winds,Bkgnds,Cards,Menus,Menu Items,Cd Btns,Cd Flds,Cd Grcs,Bg Btns,Bg Flds,BgGrcs"
  repeat with x = firstCheck to firstWhat - 1
    if hilite of cd btn x of wd id 245 is false then put false into ShowAll
    else put (item (x-3) of AbbrList) & ", " after theResult
  end repeat
  if ShowAll then put "All Objects" into theResult
  else
    delete last char of theResult
    delete last char of theResult
  end if
  return theResult
end objectsToCheck

Then just to avoid duplication, you should patch the script of the OK button in the Options window like so:

Code: Select all
on mouseUp
 put "" into oldChecks
 enum firstCheck = 4, firstWhat = 16, lastWhat = 19, lastCheck = 20
 repeat with x = firstCheck to lastCheck
  put the hilite of cd btn x into line x of oldChecks
 end repeat
 set the storedChecks of this wd to oldChecks
 
 put merge("Check:  [[objectsToCheck()&cr]]Scope:  [[whatToCheck()]]") into cd fld "Search Options" of wd id 244
 -- put "" into WhatToCheck
 -- repeat with x = firstWhat to lastWhat
 --  if (the hilite of cd btn x) then put short name of cd btn x & ", " after WhatToCheck
 -- end repeat
 -- delete last char of WhatToCheck
 -- delete last char of WhatToCheck
 -- put "" into ObjsToCheck
 -- put true into ShowAll
 -- put "Proj,Winds,Bkgnds,Cards,Menus,Menu Items,Cd Btns,Cd Flds,Cd Grcs,Bg Btns,Bg Flds,BgGrcs" into abbrList
 -- repeat with x = firstCheck to firstWhat - 1
 --  if hilite of cd btn x is false then put false into ShowAll
 --  else put (item (x-3) of AbbrList) & ", " after ObjsToCheck
 -- end repeat
 -- if ShowAll then put "All Objects" into ObjsToCheck
 -- if last char of ObjsToCheck is " " then
 --  delete last char of ObjsToCheck
 --  delete last char of ObjsToCheck
 -- end if
 -- put "Check:  " & WhatToCheck & cr & "Scope:  " & ObjsToCheck into cd fld "Search Options" of wd id 244
 set the textStyle of cd fld "Search Options" of wd id 244 to plain
 set the textStyle of word 1 of line 1 of cd fld "Search Options" of wd id 244 to bold
 set the textStyle of word 1 of line 2 of cd fld "Search Options" of wd id 244 to bold
 close this wd 
end mouseUp

I mighta missed somethin', but this should get you started...

HTH,
-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Re: Options in Search Project

Postby DaveFrancis » Sat May 19, 2018 1:20 pm

Wow, thanks a lot Mark, I really appreciate this. I'll have a go at it after breakfast ;)

Best regards, Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm

Re: Options in Search Project

Postby DaveFrancis » Sat May 19, 2018 5:31 pm

It worked like a charm Mark, thanks again.

It doesn't set my personal SP settings in stone; it goes one better and remembers whatever settings I enter. So anyone can use this version if they want the SP to remember their settings.

Great stuff!

See you in Google Groups. :)

Regards, Dave.
DaveFrancis
 
Posts: 308
Joined: Fri Mar 06, 2009 5:12 pm


Return to SuperCard Basics

Who is online

Users browsing this forum: No registered users and 1 guest