HyperNext Studio

HyperNext Studio => Getting Started => Topic started by: tools-n-stuff on October 22, 2010, 02:24:57 PM

Title: search box's [RESOLVED]
Post by: tools-n-stuff on October 22, 2010, 02:24:57 PM
Hi,
In the BookHN example there are 4 search option. I have managed to hook up another 4 and get them to work. The problem is that its taking up way to much space.

I have now added a dropdown menu/popup and added the 8 options to it. Next to this i have added a new textfield followed by a button. Does anyone know how i can hook the dropdown list options to the textfield and button. Basicly i am trying to get the the dropdown and 1 textfield and button do the same job as 8 options, textfields and buttons. I have tried looking at the popup example but can't figure it out.

Thanks in advance for any help or examples of this
Title: Re: search box's
Post by: Malkom on October 22, 2010, 04:56:33 PM
Hi

Here is a simple Popup menu holding 4 items - when selected the index number and selected item are put into 2 fields

(1) In the card script put the following code that will setup the Popup menu:-

Code: [Select]
local plist

Put 'Title' into plist
Put 'Author' after plist
Put 'Publisher' after plist
Put 'Comment' after plist

PopupSetText(1,plist)
PopupSetIndex(1,1)


(2) In the Popup menu script put the following code:-

Code: [Select]
Put PopupIndexFN(1) into field 1

Put PopupItemFN(1) into field 2

Best regards
Malcolm
Title: Re: search box's
Post by: tools-n-stuff on October 22, 2010, 08:52:56 PM
Obviously i know less than i thought!

Thanks for getting me started in the right direction, but i think i am either lost or what i want can't be done.
Displaying the results as you showed below is not quite what i am trying to do.
When the user selects something from the list i don't want it to display anything, yet! On selection i want it to activate a textfield ready for search input. At this point the user can now search based on the dropdown choice. Only when the search button is pressed will the results be displayed in a final textfield.

I imagine you are familiar with the bookHM sample!!??

I basicly want to compress the actual search system into one. Replacing all the searchboxs with just one that is activated by choice through the dropdown menu. From there on in showing the clickable results as in the example.

After looking at the guide and playing around with the bookHN searchfield, i still can't work out how connect them up.
I can see it as being theoretically possible but know nothing about programming i can't figure out if its even possible.
Maybe i am barking up the wrong tree.

regards
Dayne
Title: Re: search box's
Post by: Malkom on October 22, 2010, 11:10:46 PM
Hi Dayne

Don't be disheartened as you are certainly making progress. You just have to breakdown what you want into smaller steps.

Those buttons that carry out the search - they actually just pass 2 parameters to a global procedure called SearchFields.
The parameters are an integer that indicates which fields to search, and a word to search for.
So in the popup menu you could just use the index returned when the popup is pressed and send this index plus search term from popup to the SearchField procedure.

Just modify the previous code in the Popup menus script to:

Code: [Select]
Global searchIndex

@ Which field to search
Put PopupIndexFN(1) into searchIndex


Now you need an edit field to store the text to be searched for plus a button to carry out the seach,

If the field is number 2 then the search button script would be:

Code: [Select]
Global searchIndex
Local sword

Put field 2 into sword
Call SearchFields(searchIndex,sword)


I think this should work although I haven't tested it.

Best regards
Malkom
Title: Re: search box's
Post by: tools-n-stuff on October 23, 2010, 01:28:43 AM
I must be really thick! :?

I have tried placing your code everywhere now, and i still can't get it to work.

Please tell me exactly what page of have to put the code on.

When you say:

Quote
(1) In the card script put the following code that will setup the Popup menu:-

Code: Select all
    local plist

    Put 'Title' into plist
    Put 'Author' after plist
    Put 'Publisher' after plist
    Put 'Comment' after plist

    PopupSetText(1,plist)
    PopupSetIndex(1,1)

Please, whats the card script?

Working on 'card 2' i clicked the background to select it and then on script in 'creator properties' displaying the yellow script editor. This has the 'Card' button pressed by default displaying a page with the following code
Quote
Global searchResults

Put searchResults into field 5

Call DisplayRecord
Do i place it here somewhere and if so where?
Or do i have to hit the 'MainCode' button and place it somewhere, and if so where?

You then said
Quote
(2) In the Popup menu script put the following code:-

Code: Select all
    Put PopupIndexFN(1) into field 1

    Put PopupItemFN(1) into field 2

Does 'Popup menu script' mean click on the dropdown menu in the designer and then on the script button and place the info there?  Obviously if i can get this part sorted out, the modified code you sent will replace this part, i think thats what you meant.

Also i have noticed that on quitting the application, stack or exe, that saved info isn't stored. I have tried moding the menu button and changing Quit to QuitSave(1) it now saves only the first Page of entries. Any thoughts on that.

Sorry if i need real laymans terms, while i get my head round it all.
and thanks again
Dayne
Title: Re: search box's
Post by: Malkom on October 23, 2010, 06:48:50 AM
I think it would help you  a great deal to work through the Quick Start pdf.
The Quick Start introduces cards, their scripts, buttons etc and explains the difference between the MainCode section where startup and global procedures go - so very soon you'll know where everything belongs.

To place code in the Card script - just click on the card background then in the Properties toolbar select the Script button.
Code in the card's script runs once the card is opened so allowing you to initialize popups etc.

Best of luck.
Malkom
Title: Re: search box's
Post by: Malkom on October 23, 2010, 06:57:03 AM
Sorry, i just remembered - the Quick Start pdf pictures are older and so don't show the same Script Editor layout as that in HyperNext V3 but the  MainCode section and cards etc still work the same way.
Title: Re: search box's
Post by: tools-n-stuff on October 23, 2010, 03:38:13 PM
Thats definatly sound advice, but i have always been a hands on person. I get stuck in and learn as i go and build!
I thought this was going to be easier than it looks and once again it looks like i'm wrong.

I did notice that i'd followed your advice and code correctly so, i can't see why it won't work.

I guess if i can handle another hello world lesson i may try and go through the guide. At this stage and so close to a final product, it seems my initial euphoria was a little short lived.

Thanks anyway
Dayne
Title: Re: search box's
Post by: tools-n-stuff on October 23, 2010, 07:59:53 PM
Right i've got a general idea after going over the guide and somethings still not right.
Firstly the plist is only displaying the last option out of 8 leaving you without a choice.
Secondly the search part simply doesn't return results.

Obviously i need to read and learn (as you mentioned/suggested), but how many times do i read the guide before i give up.

For me this example doesn't work, and for you: You think it may work but you haven't tested it. (  :)  remind me not to buy a car from you)

As a user i can understand that you haven't the time to invest in noob non programmers, thats down to the software owners, (unless they don't really "understandably" care about their own "freeware" products)
I don't suppose you know of any other users or forums where i can find someone to help?

And thanks again.
Title: Re: search box's
Post by: Malkom on October 24, 2010, 09:44:55 AM
Quote from: "tools-n-stuff"
Right i've got a general idea after going over the guide and somethings still not right.
Firstly the plist is only displaying the last option out of 8 leaving you without a choice.
Secondly the search part simply doesn't return results.

As the plist is only displaying the last option out of the 8, I'm wondering if the plist does contain 8 items. Did you use the AFTER form of the PUT command for the subsequent options:-

Code: [Select]
Put **** after plist
Perhaps you could put the contents of plist into a field and see if they are what you expect:-

Code: [Select]
@ field needs to be multi-line
Put plist into field 3

Programmers spend much of their time debugging as things don't often work first time.
Using a combination of the Message command and dumping variables to fields should make your debugging much easier.

Code: [Select]
@ do something
....
....
Message var2
...
...
Message var1
Title: Re: search box's
Post by: tools-n-stuff on October 24, 2010, 06:15:34 PM
Heh heh! Well spotted!

You are correct, after pasting my 4 other additions to the plist i forgot to change them from 'into' to 'after':
As for displaying the result, my bad, i forgot to tell the button where to display.
So basicly it works, except for one small thing that i have spent the last 2 hours trying to find.

The plist is not showing as a list but as one line of text.
I 'think' that it has something to do with this:

PopupSetText(1,plist)
PopupSetIndex(1,1)

I have tried changing values, removing one line at a time and even both. Yes there are changes each time but not the one i want.

I will go back now and try to work it out. I will come back and let you know if and when i get it to work.
Unless you manage to see this before i do and you have the solution.

cheers


TAKE 2:
Ok back again.
I have tried to put the plist into a firld as you suggested and it displays as a list, good.
But the drop down list is still showing as one line and not as a list!!??
Title: Re: search box's
Post by: tools-n-stuff on October 25, 2010, 01:34:43 AM
I have spent the whole day going over the quick start and reference guide and i still can't get the list to show as a list. It continues to display as a single line of text.

I don't know if you read the post just before this one!? But basicly it works, but it will only search for the Title. I believe this is because the whole list is on one line and im hoping that when the list becomes a list it will allow a full search through all fields.

regards
Dayne
Title: Re: search box's
Post by: Malkom on October 25, 2010, 09:45:17 AM
Quote from: "tools-n-stuff"
I have spent the whole day going over the quick start and reference guide and i still can't get the list to show as a list. It continues to display as a single line of text.

I don't know if you read the post just before this one!? But basicly it works, but it will only search for the Title. I believe this is because the whole list is on one line and im hoping that when the list becomes a list it will allow a full search through all fields.

The problem is to do with line-ending characters inside controls and that Macintosh Windows and Unix all have different line-endings  - there are some notes on this in the Help section on Strings.

if you modify the card's script to this:-

Code: [Select]
local plist,endline

Put 'Title' into plist
Put 'Author' after plist
Put 'Publisher' after plist
Put 'Comment' after plist

@ set line endings for Windows platform
Put EndLineFN(3) into endline
Put ReplaceEndsFN(plist,endline) into plist

PopupSetText(1,plist)
PopupSetIndex(1,1)
Title: Re: search box's
Post by: tools-n-stuff on October 25, 2010, 12:58:26 PM
Thanks for that!
I have gone over the strings section in the guide but it only says what you can place. It doesn't help explain where and why, which is obviously what i need because your new addition to the code gives back an error message as follows:

  ^ Invalid destination
Put EndLineFN(3) into endline

I have once again tried to change a couple of things and at best i get an empty dropdown menu with space for a list of 2 lines. So i put the code back to the way you changed it.

Im sorry i can't get my head round this yet, i am used to HTML, 3DML and Flash(3DFA), and installing and themeing forums (phpbb, simplemachine etc)
Title: Re: search box's
Post by: Malkom on October 25, 2010, 03:15:55 PM
Quote from: "tools-n-stuff"
Thanks for that!
I have gone over the strings section in the guide but it only says what you can place. It doesn't help explain where and why, which is obviously what i need because your new addition to the code gives back an error message as follows:

  ^ Invalid destination
Put EndLineFN(3) into endline

I have once again tried to change a couple of things and at best i get an empty dropdown menu with space for a list of 2 lines. So i put the code back to the way you changed it.

Im sorry i can't get my head round this yet, i am used to HTML, 3DML and Flash(3DFA), and installing and themeing forums (phpbb, simplemachine etc)

Did you remember to declare endline as a local variable?

About the String Help - i usually use the Built-In help via the menu bar as its much quicker than using the Language Reference PDF. Although both need updating. Unfortunately for newcomers to programming there are a lot of gotchas - like endofline chars - that experienced programmers hardly have to think about - its just a matter of building up experience.
Title: Re: search box's
Post by: tools-n-stuff on October 25, 2010, 06:50:14 PM
Oh man, i am at the point of giving up, 3 days wasted on a damn dropdown menu. I bet your having a good old laugh at my expense.

No i hadn't declared endline as a variable and now that i have it shows the list but wont send back the search results.
Once again i have looked everywhere to try and find the solution.

I don't suppose you have a working example i can use, because getting bits of info every now and again is doing my head in and its not helping me learn or understand what i am doing.

Thanks again for being patient!
Title: Re: search box's
Post by: Malkom on October 25, 2010, 07:57:22 PM
Quote from: "tools-n-stuff"
Oh man, i am at the point of giving up, 3 days wasted on a damn dropdown menu. I bet your having a good old laugh at my expense.

No, seriously its no laughing matter - I'm programming seven days a week and most days I do something damn silly or miss the obvious - but thats the nature of programming. Look in any programming forum and you'll see the same - everything is easy with hindsight.

Anyhow, you know you have made a lot of progress and have spotted how certain types of bugs can occur - spelling mistakes, variables not declared etc, side effects you didn't know about ......



Quote from: "tools-n-stuff"
I don't suppose you have a working example i can use, because getting bits of info every now and again is doing my head in and its not helping me learn or understand what i am doing.

Thanks again for being patient!

The Search routine just takes some values and then places some results in a field - you could put some debug messages inside the Search routine and see where things go wrong - then you will have cracked it.
Title: Re: search box's
Post by: tools-n-stuff on October 25, 2010, 09:41:29 PM
Now i don't understand whats going on.
Where-as i said before the plist is place, but not sending the search results back. Well it is now. All i have done is switch my PC off and come back a couple of hours later and the damn thing is working. I don't get it!

Ok its not working entirely as it only sends results back from the first plist item, but i guess i will eventually find it (probably with your help).

As for adding a debug message, well you got me again.

In the 3d markup language i use i only have to add <debug> at the top of the page and it does the job when trying to run the 3D environment. If there is a bug somewhere then it will show, what and where.

I tried this in HN but that returned as a bug  :D

Anyway, im off to see if i can find out why the plist only works for the first item
Title: Re: search box's
Post by: tools-n-stuff on October 26, 2010, 01:29:03 PM
I spent most of last night and this morning going over the guides (built in and online) and can't work out why it only works on the 1st plist item.

Now knowing you program 7 days a week, i imagine asking you to look over my project is out of the question?
Title: Re: search box's
Post by: Malkom on October 26, 2010, 01:37:30 PM
Quote from: "tools-n-stuff"
I spent most of last night and this morning going over the guides (built in and online) and can't work out why it only works on the 1st plist item.

Now knowing you program 7 days a week, i imagine asking you to look over my project is out of the question?

Its fine - its just that often I can't answer forum questions quickly.

If you can post the code for the Search routine and the outputs then we might be able to find the problem - and so help other forum readers as well :)
Title: Re: search box's
Post by: tools-n-stuff on October 26, 2010, 02:04:01 PM
MODIFIED - names only

Thats great thanks, and i can understand your lack of time, i wasn't having a go at you  :oops:

Just a thought, maybe this whole thread could be moved to 'Interface Controls'

This is from the searchfields in the main code:

Quote
@ --- Get list to search ---
If fnum=1 Then
   If fnum=1 Then
    Put titleVar into searchlist
EndIf
If fnum=2 Then
    Put authorVar into searchlist
EndIf
If fnum=3 Then
    Put publisherVar into searchlist
EndIf
If fnum=4 Then
    Put commentVar into searchlist
EndIf
If fnum=17 Then
    Put dateVar into searchlist
EndIf
If fnum=18 Then
    Put languageVar into searchlist
EndIf
If fnum=19 Then
    Put salesVar into searchlist
EndIf
If fnum=20 Then
    Put otherVar into searchlist
EndIf

Put LinesFN(titleVar) into nbooks

Clear searchResults

For n=1 to nbooks
      Put line n of searchlist into buff
      Put FindWordFN(buff,sword) into wpos
      If wpos>0 Then
         Put n after searchResults
      EndIf      
EndFor

Put searchResults into field 5

And this is from the card:
Quote
Local plist

Put 'Title' into plist
Put 'author' after plist
Put 'Publisher' after plist
Put 'Comment' after plist
Put 'Date' after plist
Put 'Language' after plist
Put 'Sales' after plist
Put 'Other' after plist

@ set line endings for Windows platform
Local endline
Put EndLineFN(3) into endline
Put ReplaceEndsFN(plist,endline) into plist

PopupSetText(1,plist)
PopupSetIndex(1,1)

Global searchResults

Put searchResults into field 5

Call DisplayRecord

and finaly this is the button script:
Quote
Global searchIndex
Local sword

Clear field 5

Put field 21 into sword
Call SearchFields(searchIndex,sword)

I think thats all is needed, but please correct me if i am wrong.
I guess from the plist you can guess what i am trying to achieve!

MODIFIED - names only
Title: Re: search box's
Post by: Malkom on October 26, 2010, 05:13:05 PM
Thank you for all the details it makes things a lot clearer.

Just wondering - in the script for the PopupMenu do you have this or something similar assuming that the PopupMenu is number 1?

Code: [Select]
Global searchIndex

Put PopupIndexFN(1) into searchIndex
Title: Re: search box's
Post by: tools-n-stuff on October 26, 2010, 06:58:08 PM
OOPs! I forgot to mention that one, i have as follows:

Code: [Select]
Global searchIndex

@ Which field to search

Put PopupIndexFN(1) into searchIndex
Put PopupTextFN(1) into searchIndex
Title: Re: search box's
Post by: Malkom on October 26, 2010, 07:23:34 PM
Quote from: "tools-n-stuff"
OOPs! I forgot to mention that one, i have as follows:

Code: [Select]
Global searchIndex

@ Which field to search

Put PopupIndexFN(1) into searchIndex
Put PopupTextFN(1) into searchIndex

ah - we might have found it - the second Put statement overwrites the value of searchIndex so you only need

Code: [Select]
Global searchIndex

@ Which field to search

Put PopupIndexFN(1) into searchIndex

I originally put that second Put statement in as a way of placing the Popuomenu's text into a field for debugging purposes.
Title: Re: search box's
Post by: tools-n-stuff on October 26, 2010, 07:48:54 PM
Excellent its working, except a couple of fields not returning the search results, but i really think that's all down to me. Last week i came across HyperNext and i know nothing about building applications, I have shaken my brain every day since and i think i have lost my self in the info and naming  :oops:  This one i have to work out formyself  :lol:
I can't say how much i appreciate your help, and not to forget the fact that HyperNext is even there.

I feel like a big kid with a new toy.
Title: Re: search box's
Post by: Malkom on October 26, 2010, 08:43:40 PM
Thats really great progress you've made - all in just a week - perseverance - i just hope you remember to have rest sometimes. :)
Title: Re: search box's [RESOLVED]
Post by: tools-n-stuff on October 27, 2010, 12:48:01 AM
Ok! as mentioned in my last post, i thought it was down to me. Yup! Sure was. Because of my confusion amongst the field names and texts names and the fact that i just started to build on top of the original Book HN without giving it any thought. I found myself adding components, changing my mind, removing them and the code was a real mess. So i decided to clean it up so that a text name corresponds with its field name, obviously doing the necessary to make sure i kept track of what code came from what button etc so as to build everything tidily and replace the code. I thought it would make it easier to find the problem with everything in order!
And then i broke it, i broke the whole damn thing. What a nightmare! Since the precise time marked on my last post and the time on this one that is the time iv'e spent trying to figure it out.
Thankfully though and after a few hours i managed to sort it all out. Yes, talk about happy!
Along the way i found that i hadn't declared a couple of variables and one even had its space 'comma' between the name and the Var ('name,Var' and not 'nameVar,' ) This led me onto see the difference between the field and the field name and discover other problems for the search and saving etc.
And that maybe, certain components can be outligned black if there is a conflict or something. Not sure on that one though.
There remains just two problems and that is:
1)  i can't see how to make the search return multiple finds. But thats possibly because i haven't looked yet i was just happy with a fully functional drop down search system.
2) i also have a ghost button that just wont go away. It has been deleted, but remains in the card script.
Even with those two small issues, i actually started to see the logic. Sure i have a whole load of questions for you, and i know im gonna do your head in head. But i will save them for another thread and another day.
I have other issues to look at now like maths, what seems to be the built in registration system, password login if possible, saving the imported image to the data/arrays and displaying the saved info into a second page. Clone a card would be handy.

Its 1.45 am and i am going to have a quick 'celebratory' beer, before turning in. Tomorrows going to be a busy day  8-)
Title: Re: search box's [RESOLVED]
Post by: Malkom on October 27, 2010, 09:40:51 AM
Quote from: "tools-n-stuff"
Ok! as mentioned in my last post, i thought it was down to me. Yup! Sure was. Because of my confusion amongst the field names and texts names and the fact that i just started to build on top of the original Book HN without giving it any thought. I found myself adding components, changing my mind, removing them and the code was a real mess. So i decided to clean it up so that a text name corresponds with its field name, obviously doing the necessary to make sure i kept track of what code came from what button etc so as to build everything tidily and replace the code. I thought it would make it easier to find the problem with everything in order!
And then i broke it, i broke the whole damn thing. What a nightmare! Since the precise time marked on my last post and the time on this one that is the time iv'e spent trying to figure it out.
Thankfully though and after a few hours i managed to sort it all out. Yes, talk about happy!
Along the way i found that i hadn't declared a couple of variables and one even had its space 'comma' between the name and the Var ('name,Var' and not 'nameVar,' ) This led me onto see the difference between the field and the field name and discover other problems for the search and saving etc.
And that maybe, certain components can be outligned black if there is a conflict or something. Not sure on that one though.
There remains just two problems and that is:
1)  i can't see how to make the search return multiple finds. But thats possibly because i haven't looked yet i was just happy with a fully functional drop down search system.
2) i also have a ghost button that just wont go away. It has been deleted, but remains in the card script.
Even with those two small issues, i actually started to see the logic. Sure i have a whole load of questions for you, and i know im gonna do your head in head. But i will save them for another thread and another day.
I have other issues to look at now like maths, what seems to be the built in registration system, password login if possible, saving the imported image to the data/arrays and displaying the saved info into a second page. Clone a card would be handy.

Its 1.45 am and i am going to have a quick 'celebratory' beer, before turning in. Tomorrows going to be a busy day  8-)

Job well done - congratulations - now we can start a new thread :)

About the ghost button - thanks for reporting it - I thought that bug was fixed a long time but clearly not.
I wonder if the button is still on the card - but has gone out of bounds. On the Properties toolbar is a small button "IV" - its for fetching out of bound controls back into view.
Title: Re: search box's [RESOLVED]
Post by: tools-n-stuff on October 27, 2010, 10:38:37 AM
No, its not a bug you must have fixed it.
I hadn't even noticed that 'IV' button. Nice option.