Looking for an example stack of a address book, etc.

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Looking for an example stack of a address book, etc.

Postby chuckm » Sat Aug 12, 2017 11:16 pm

Hi,

I'm working through teaching myself to use LiveCode. The BYU book was unfortunately not helpful to me at all (others mileage may vary). What I usually do is an address book or some other type of simple editor just to kick the tires. While creating one that uses buttons to move back and forth is relatively simple, I am trying to create the following dialog:

Code: Select all
+----------------------------------------------+
| +--------------+     First Name:             |
| |             ^|     [_________________]     |
| |              |                             |
| |              |     Last Name:              |
| |              |     [_________________]     |
| |              |                             |
| |              |     Address:                |
| |              |     [                     ] |
| |              |     [                     ] |
| |              |     [                     ] |
| |              |     [                     ] |
| |             v|                             |
| +--------------+                             |
| [+][-]               [Close] [Cancel] [Edit] |
+----------------------------------------------+



Where the list control on the left is used to select the card to display. Where I'm hung up is how/where to accomplish the following:

1. Display a blank card on opening the deck.
2. Populate the list control based on the cards already in the deck.
3. Do the actual card selection/display based on clicking the name in the list.

For what it's worth, clicking the Edit button gets the card into Edit mode and the Save Button appears in place of the Edit button. It's a pretty basic app, but after several evenings of reading the docs (all of them) and looking for similar examples (nonexistent as near as i can tell), I'm stumped.

Any help is appreciated and thanks in advance.
chuckm
 
Posts: 9
Joined: Sun Jun 19, 2016 12:30 am

Re: Looking for an example stack of a address book, etc.

Postby bogs » Sat Aug 12, 2017 11:46 pm

Welcome, chuck :)

chuckm wrote:1. Display a blank card on opening the deck.
I think this would be a good place to create a template card, or copy of the card you have laid out. In the openStack handler, you could put something like:
Code: Select all
on openStack
   go card "blankForm" // whatever you've named the blank card you want to open with...
end openStack

2. Populate the list control based on the cards already in the deck.

For populating the list, I would tend to use repeat, the dictionary has lots of fair examples, the gist of it would look like...
Code: Select all
// whatever handler name you choose, but for example...
on popList
// if all  your cards are in the stack, if they are in a different stack, make sure to specify...
       repeat with x = 1 to the number of cards of this stack
           put the [long, short, abbreviated] name of card x & cr after myList   // your listbox...
      end repeat
end popList


All of the above is off the top of my head, and I'd compare that to a good head of cabage :lol: so I'm sure others would be able to specify more if you need it.

You said BYU didn't do it for you, I'd suggest poking around here and
here and see if either does better by you.

Some lessons on the site that might help are moving to different cards, and while your there, you might want to work through the text lessons as well, they would probably be handy.

Good luck :)
Image
bogs
 
Posts: 260
Joined: Sat Feb 25, 2017 10:45 pm

Re: Looking for an example stack of a address book, etc.

Postby AndyP » Sun Aug 13, 2017 11:11 am

This example from Livecode lessons might start you off.

http://lessons.livecode.com/m/datagrid/l/7305-example-creating-a-list-of-people
Andy Piddock

http://2108.co.uk/tinyide/ - TinyIDE gives you more space to develop your ideas

http://2108.co.uk/script-editor-themer/ Script Editor Themer - Your code has never looked so good

My software never has bugs. It just develops random features
AndyP
 
Posts: 287
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)

Re: Looking for an example stack of a address book, etc.

Postby dunbarx » Sun Aug 13, 2017 2:09 pm

Welcome to LC.

It takes a bit of time and effort to get going; the initial apparent simplicity of LC belies its vastness and richness.

Bogs has given good advice. Think rolodex. The thing to get hold of as a new user is that if one an access the information on the various cards in a stack, one can collect that data in a variable (even without actually navigating to those cards) and then simply "put" that data into a list field, say, on the "working" card.

Display a blank card on opening the deck.

Why would you want this? Wouldn't it be more useful to display a well formed "working" card, with all the right controls in place? There is no reason to reconstruct those controls each time you open your stack. You can, and I think this is what you meant, EMPTY the contents of those controls each startup.

Once you have your list field populated, a "mouseUp" handler in that field can do something like (pseudo)
Code: Select all
go to the card that the use clicked on


You are one of the few new users that actually wanted to start with a simple app to learn LC. Most jump right in with DataGrids, which is trying to learn how to fly in an F-14.

Write back often. We love to talk.

Craig Newman
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 4760
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Looking for an example stack of a address book, etc.

Postby bogs » Sun Aug 13, 2017 2:46 pm

dunbarx wrote: Wouldn't it be more useful to display a well formed "working" card, with all the right controls in place?
Thank you for reminding me, I also meant to suggest studying grouping controls, and using as a shared background! If you group all the editing controls, you'd only have to write the code for those one time, setting them as "behave like a background" will put them on every card, letting you edit already created entries right from the card your on at the time.

@Andy - thank you, I seem to be missing that one heh, but as Craig mentioned, the dg is a complicated beast for most.

The thing chuck will want to remember as he looks through that lesson is that he will need to generalize the coding for putting the information in, since hard formatting the input like they do will serve no purpose (unless you want to have 50 cards with a limited set of names).

*Edit - at some point, I plan to liberate and update all the old old tutorials from Mc 2.5, unfortunately that will be too long in the future to be of help to you on this topic. They actually had one for just this project :(
Image
bogs
 
Posts: 260
Joined: Sat Feb 25, 2017 10:45 pm

Re: Looking for an example stack of a address book, etc.

Postby richmond62 » Sun Aug 13, 2017 3:32 pm

Get your hands on a Macintosh computer that runs system 8-9 and then
trawl the internet for Hypercard stacks of address books.

There must be hundreds out there. There is no real need to rewrite the wheel.

Oh, and . . . .

https://archive.org/details/mac_Danny_G ... Guide_1988

I found these on one of my old machines:
oldNonsense.zip
Hypercard Address Books
(69.2 KiB) Downloaded 5 times
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
 
Posts: 1826
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Looking for an example stack of a address book, etc.

Postby bogs » Sun Aug 13, 2017 3:59 pm

Richmond, I actually have an old mac+, but I wouldn't have thought to try and use it for this ha ha. The reason I'd be pulling and trying to update those old tut's is that they were really well done.

Awesome on the link to the book of Danny G's, I'd thought it was lost to the ether. Now it is safely on my disk for access :)
Image
bogs
 
Posts: 260
Joined: Sat Feb 25, 2017 10:45 pm

Re: Looking for an example stack of a address book, etc.

Postby dunbarx » Sun Aug 13, 2017 4:48 pm

I had no idea Dan's Developer Guide was available for download. But what is really required is the "Handbook". Anyone know if that is around?

I often suggested that a new user read that volume, or at least skim it. I still think that is useful, the differences between HC and LC notwithstanding.

Craig
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 4760
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Looking for an example stack of a address book, etc.

Postby richmond62 » Sun Aug 13, 2017 5:17 pm

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
 
Posts: 1826
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Looking for an example stack of a address book, etc.

Postby jacque » Sun Aug 13, 2017 9:15 pm

Where I'm hung up is how/where to accomplish the following:

1. Display a blank card on opening the deck.
2. Populate the list control based on the cards already in the deck.
3. Do the actual card selection/display based on clicking the name in the list.


There are probably dozens of different ways to do this and what I'm going to suggest isn't really the best way, but it might be the easiest way when you're just starting out. Like Craig, I congratulate you on choosing a simple project to begin with, it's exactly the best way to proceed.

I would create a group that contains all the controls in your diagram. Set the group to act like a background in the property inspector. That way it will appear on every card. Name it something, I'll call it "template".

The fields in the group should not be set to share their text (the sharedText property is false.) You can set that in the field property inspector. This makes each field contain text unique to each card. The one exception should be the list field, which should share its content. (I'd probably make the list its own separate group, but for now it doesn't matter.) Name the list field something; I'll use "list".

When the stack opens, run a preOpenStack handler (put it into the stack script) that puts empty into each field and puts the names of all the cards into the list:

Code: Select all
  on preOpenStack
    repeat with x = 1 to the number of fields in group "template"
      put empty into field x of group "template"
    end repeat
    put the cardnames of this stack into field "list"
  end preOpenStack


When the stack opens, you should see an empty template that contains only the list of card names. Until you have some content, the list will contain only one line and it will begin with "card id xxxx". You can fix this later, leave it for now.

Rather than a Close button, I'd use a Save button. When the user clicks it, it will name the card for the first and last name fields, add that name to the list, and save the stack:

Code: Select all
on mouseUp -- script of Save button
  set the name of this card to (field "first name" && field "last name")
  put the cardnames of this stack into field "list"
  save this stack
end mouseUp


The script of the list field can be like this:

Code: Select all
on mouseUp
  get the text of the hilitedline of me
  go card it
end mouseUp


I'd also add a New button, otherwise this example will always only have a single card. The script of the New button:

Code: Select all
on mouseUp
  create card
end mouseUp


This will add a new card with empty fields, ready to type into.

That should get you started. See if you can figure out how to remove the single unnamed card in the list when the app has no content yet. Also for this method, you don't need an Edit button. The user can just click Save after changing the content.

The Cancel button would have to delete the currently unnamed card. See if you can figure out how to decide whether the card hasn't been saved yet.

Once you have this working, I'd move on to a different method of doing the same thing, which would involve storing the data entries as custom properties of the stack and using only a single card to display the user's choice (this will likely get you into using arrays.) This will be a little more complex.

And once that is done, you might want to experiment with using a database to store the content and loading the user entries into a single template card from there. I'm not sure I'd use a database for an address book where there the amount of data isn't usually very large, but it would be another way to learn more.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3698
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: Looking for an example stack of a address book, etc.

Postby chuckm » Sun Aug 13, 2017 9:41 pm

dunbarx wrote:Welcome to LC.

It takes a bit of time and effort to get going; the initial apparent simplicity of LC belies its vastness and richness.

Bogs has given good advice. Think rolodex. The thing to get hold of as a new user is that if one an access the information on the various cards in a stack, one can collect that data in a variable (even without actually navigating to those cards) and then simply "put" that data into a list field, say, on the "working" card.


The rolodex is the mental picture I'm working from. Great minds? :D

Display a blank card on opening the deck.

Why would you want this? Wouldn't it be more useful to display a well formed "working" card, with all the right controls in place? There is no reason to reconstruct those controls each time you open your stack. You can, and I think this is what you meant, EMPTY the contents of those controls each startup.


This is one of the terminology issues that I'm struggling with. When the deck is opened, no name should be selected so the form should be empty. Per another comment, perhaps I need to set the grouped controls up as a background (need to look more into backgrounds).

Once you have your list field populated, a "mouseUp" handler in that field can do something like (pseudo)
Code: Select all
go to the card that the use clicked on


Makes sense because you want the event to trigger after the button has been released not depressed.

You are one of the few new users that actually wanted to start with a simple app to learn LC. Most jump right in with DataGrids, which is trying to learn how to fly in an F-14.


I've been writing software for a long time so I know that it's better to start simple and iterate your way to unmanageable complexity rather than start there. :-) Realistically, the address book is a component of a larger personal information application design that I'm using to learn LiveCode. Eventually, I believe that it will need to become a substack from the main PIM application (feel free to correct me if my understanding or use of terminology is incorrect). I'm keeping notes so when I'm done I may turn the whole thing into a series of blog posts or something else for documentation for new users.

Write back often. We love to talk.

Craig Newman


Oh, you'll find that I have no pride (or shame) when asking for assistance. When I started writing software some time ago (no, I won't say how long but I do know COBOL and Fortran) I was fortunate to work with some great mentors who allowed me to stand on the shoulders of giants. It was a great learning experience both from a technology perspective and from learning to approach new things from a position of humility rather than pride or arrogance.
chuckm
 
Posts: 9
Joined: Sun Jun 19, 2016 12:30 am

Re: Looking for an example stack of a address book, etc.

Postby bogs » Mon Aug 14, 2017 12:20 am

richmond62 wrote:https://archive.org/details/The_Complete_HyperCard_Handbook
You are awesome x infinity, I bow before your search - foo efforts :!:
Image
bogs
 
Posts: 260
Joined: Sat Feb 25, 2017 10:45 pm

Re: Looking for an example stack of a address book, etc.

Postby chuckm » Fri Aug 18, 2017 4:02 am

Thanks for the link. I've been reading through it, and while there is a lot of information, the OCR job is pretty rough in spots. Still slogging through things, but no real progress as of yet. Looks like the learning curve is a lot steeper than I thought it would be. Is this typical of people who are new to Livecode?
chuckm
 
Posts: 9
Joined: Sun Jun 19, 2016 12:30 am

Re: Looking for an example stack of a address book, etc.

Postby jacque » Fri Aug 18, 2017 5:48 am

I don't think I'd start with that book. While much of it is relevant, a lot of it is obsolete too.

You just need to pick up a few main concepts, and the rest will fall into place. You might have better luck working through at least the first few stacks (in order) here :

http://hyperactivesw.com/revscriptconf/scriptingconferences.html

It is normal and very common for new users to be frustrated for a few weeks because there's a critical mass you have to know before the pieces fall into place. Once that happens it's smooth sailing. The above stacks were created specifically for new users to help them get over the initial learning curve.

It's also normal for users who are fluent in other languages to have a little trouble unlearning what they already know. LiveCode is a different animal, but usually once the penny drops you're hooked. We have a lot of users who don't want to go back to other languages once they learn LiveCode.

And we're here to help whenever you get stuck.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3698
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: Looking for an example stack of a address book, etc.

Postby FourthWorld » Fri Aug 18, 2017 6:57 am

Which sections of the User Guide have you read?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5256
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Next

Return to Getting Started with LiveCode - Experienced Developers

Who is online

Users browsing this forum: Bing [Bot] and 3 guests