Multiple Windows

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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
saratogacoach
Posts: 87
Joined: Thu Jul 17, 2008 8:42 pm

Multiple Windows

Post by saratogacoach » Mon Jun 15, 2009 12:20 pm

Hi,

As a beginner, I am trying to use relevant projects that will help me learn RunRev. I have an older eLearning project done in another program that I would like to re-develop in RunRev, focused on wellness promotion.

2 separate parts, each with multiple screens (perhaps 50+) and some interactive components: Likert scale quizs/surveys(check box's for strongly agree, agree, undecided, disagree, strongly disagree, scores ranging from 5 to 1). These surveys will be a coding challenge: if I can create a basic code for this (pseudocode: if box 1 is checked, add +5 to score, if box 2 is checked, add 4 to score, etc.), I will eventually be able to adapt it to a 75 item survey, show the survey-taker score results at the end.

But first, I need to figure out a very basic feature: how best to create multiple windows within the same project, for the user to navigate between. I'm not sure if this means using stacks, sub stacks, cards: still confused. :?

Any suggestions appreciated.

Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Mon Jun 15, 2009 4:48 pm

You would use a main stack with substacks within the same project and open each stack as needed when needed. It's been a while since I personally did that and don't remember exactly what commands/functions you would need, but yes, you can do that with Rev. :-)

I found one of my projects that does this and here's a small example of working with multiple stacks.

Code: Select all

on openStack
  go stack "mgdtools"
  go stack "mgdprops"
  go stack "designwindow"
  hide stack "designwindow"
  go stack "mgdmain"
end openStack
I'm not sure what I have going there, but you can see to open the other stacks the commands "go" and "stack" are being used to open the other stacks. One stack you can see is being hidden with "hide" and "stack".

So at least there's a few commands you can look up in the help/docs.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

saratogacoach
Posts: 87
Joined: Thu Jul 17, 2008 8:42 pm

Post by saratogacoach » Mon Jun 15, 2009 5:20 pm

Thanks, Garrett.

I've done some reading and experimenting with this.

I think where I intially went wrong was checking the stack's inspector box for "visible" and then using the command

Code: Select all

set the visible of stack "stack name" to false


to hide a stack. Looks like "hide" is the correct command. If I set up a nav button to open a specific stack and at the same time hide the current one, hopefully that will work.

Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Tue Jun 16, 2009 12:52 am

I do believe that will work as you want it :-)
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

saratogacoach
Posts: 87
Joined: Thu Jul 17, 2008 8:42 pm

Post by saratogacoach » Tue Jun 16, 2009 4:42 am

Hi,

Yes, this works for creating a simple interface and navigation.

Now I need to figure out how to set up a survey question where the survey taker selects one of 5 choices (using a group of radio buttons), each choice scored differently (strongly agree=5 points, agree=4 points, undecided=3 points, disagree=2 points and strongly disagree=1 point).

There are 70 survey questions, so the app needs to add/store each choice's points in a total score variable and display the final total score at the end of the completed survey.

Need to figure out a script to read the selected radio button in order to add its point score to the total score variable.

Any suggestions appreciated.

Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Post by acidjazz » Tue Jun 16, 2009 5:12 am

Hi saratogacoach,
Depending on what you're doing, you are often best off using just ONE card, and simply looping through the questions or instructions. Granted, you may want to use separate stacks for the quiz versus the tutorial, but even those can often be merged into a single card each! Let's say you have a survey with 50 questions. Just for fun, I'll also assume that you have a different graphic associated with each question, and you want that to appear on the card too. First, put your questions into a global variable called myQuestions in the stack script, like this:

Code: Select all

put "This is the first question" & CR after myQuestions
put "This is the second question" & CR after myQuestions
etc.
Then on the card, let's say you had a rating scale in the form of 5 regular button, named 1,2,3,4, and 5 (and then you could put verbal anchors (e.g., "strongly agree") in a text box underneath the button if you wanted. After naming the buttons, you would simply put identical code inside each button (although see my note about Rev 3.5 and "behaviors" below). The code would look like this:

Code: Select all

on mouseUp
       put the name of me & comma after gResponse
       add 1 to i
       If i > 50, [b]then 
            go card "Done!" 
       else
           put line i of myQuestions into field "Question"
       end if 
end mouseUp
Line 1: I assume you've named your buttons 1,2,3,4 corresponding to your scale. They could also be named "Yes" "No" "Maybe" etc. Depends on what you're doing with the data. "Put...& comma...after" appends each response (i.e., the name of the button clicked) so that responses to all 50 questions are stored (separated by a comma) in a single variable called "gResponse". This variable needs to be global to hold the values for the entire experiment. You can always access the response to the xth question later by calling "item x of gResponse" You can also separate responses by CR (carriage return) and tab.
Line 2: This is your standard counter. Your counter variable "i" must be global so that it keeps its value until the next iteration.
Line 3: If you have 50 survey items, then this will kick you out of the loop (onto a second card called "Done!") when participant has answered them all.
Line 4: If the participant hasn't finished all 50 items, then this will display the next question in the survey. Note that you could have multiple lines that also displayed graphics and pictures associated with the question. If you have images stored and named neatly in a folder (e.g., pic1.jpg, pic2.jpg, etc.) you could simply use these two lines to display the picture associated with the text at the same time:

Code: Select all

     put "c:\mypictures\pic" & i & ".jpg" into piclocation
     set the filename of image "myImage" to piclocation
On question #1, it will display pic1.jpg in the container called "myImage" that is on your card. Finally, let's say you have three different types of questions you ask in the survey. You could make each question into a group, put them ALL onto the card (on top of each other), but only display the one that is relevant, perhaps by using a switch statement

Code: Select all

switch i
      case 1 
         set the visible of group "True/False" to true
         set the visible of group "rating scale" to false
         set the visible of group "open ended" to false
         break
      case 10
      case 15
      case 40
         set the visible of group "True/False" to false
         set the visible of group "rating scale" to true
         set the visible of group "open ended" to false
         break
      default
         set the visible of group "True/False" to false
         set the visible of group "rating scale" to true
         set the visible of group "open ended" to false
         break
   end switch
end mouseUp
In this example, the first of your 50 questions (the case where i = 1) will display the true/false option, questions# 10,15, and 40 will display the rating scale, and all the other items will display the open ended question.
This whole approach uses just one card (well, maybe three counting the "Done!" card, and a "splash" card). And even though it seems like more work, is usually easier in the long run, because if you have problems, the code is all in one location, and thus easier to fix. (NOTE: In Revolution 3.5 you could put the code in just one button make it a "behavior", and then have the other buttons just call that code. That way if you change the code, you only have to change it once and all the other buttons will reflect the change.
Oh, almost forgot, to store the response of radiobuttons instead of regular buttons like I assumed above, you'd first set them so none of them are selected. Right when you make them visible, do this too:

Code: Select all

set the hilitedButton of group "radiobutton" to zero
When using radio buttons, I tend to use a separate continue button. The continue button would have the same code as I used above (i.e, add 1 to i, If i > 50... etc.) but instead of this line:

Code: Select all

     put the name of me & comma after gResponse
You'd modify a bit to say this:

Code: Select all

on mouseUp
     global gResponse
     If the hilitedButton of group "radiobutton" = zero then
          answer "Oops!  You forgot to answer"
     else          
          put the hilitedbuttonname of group "radiobutton" & comma after gResponse  
     end if
end mouseUp
Finally, to get total score you could write your own handler (essentially a subroutine that you'd call) that said something like this:

Code: Select all

on CalculateTotal
   repeat for each item x in gResponse
      add x to myTotal
   end repeat
   answer "You have a total score of" && x 
end CalculateTotal
myTotal should be global if you wish to use it outside of this handler.

I was just working on a project yesterday to do all this, so the timing was perfect. Hope it actually helps. If others think I've offered bad advice, please chime in. I'm still relatively new at this myself!

BTW, I'm curious what program you used to originally code this?

- Good Luck!
Mark P.

churchken
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Sun Apr 15, 2007 2:54 pm

total scores

Post by churchken » Tue Jun 16, 2009 5:49 am

Saratoga,

If you want a very simple approach to score the question responses, I have an example you may find helpful. I don't know how to post a rev file here in the board, but would be glad to email the sample to you. My email is kchurchill@comcast.net

The sample assigns a group number to each question's answers, and puts the question response value in a simple field line equal to the question's number. Then a total button gives the totals.

Regards,
Ken

saratogacoach
Posts: 87
Joined: Thu Jul 17, 2008 8:42 pm

Post by saratogacoach » Tue Jun 16, 2009 1:54 pm

Hi Mark, Ken,

Thanks for your help and suggestions.

Mark, I will study this. I suspect it can help me learn a lot. The original was done in Opus.

Ken, I've written by email. Thanks for your kind offer.

Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Post by acidjazz » Wed Jun 17, 2009 1:40 am

No problem. My "CalculateTotal" handler would be the sort of code you could put into Ken's button (although he may be summing along as he goes, whereas I wait till the end and then add 'em up). I'm not quite sure what Ken is referring to when he says "assigns a group number to each question's answer.

Ken would you be willing to post some of your code here?

Cheers,
Mark

churchken
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Sun Apr 15, 2007 2:54 pm

survey concept

Post by churchken » Wed Jun 17, 2009 5:58 am

Mark,

Finally figured out how to post to the user's section and placed the sample stack there under my user name "churchken" .

http://revonline.runrev.com/channels/us ... c.gz?Users

If multiple cards are used to accomodate the number of questions needed, the "scores" can all be stored in the field located on the first card. The score field could be set as not visible, so only the grand totals would be visible when calculated.

Just a rough idea on how to approach the concept.
Ken

saratogacoach
Posts: 87
Joined: Thu Jul 17, 2008 8:42 pm

Post by saratogacoach » Wed Jun 17, 2009 2:58 pm

Hi,

Being a beginner, I probably created a little less efficient model, adapting from your suggestions, reading online, etc.

I set up a global variable on each substack (about 20 all together), so the score total on each substack can persist. Then I plan (haven't finished yet) to declare all of these on the "display results" last substack and put them into a global variable for total score (which I can hopefully then display).

Right now, the interface is a bit messy: I have to improve navigation so that when going from one substack to the nexxt, the previous one "hides."
I guess another way would be th precisely superimpose each next substack on the ones before it, to cover them. But, I think this leaves the user to close each opened substack, when they want to exit. A bit messy...

But, it's a good learning experience...

The other issue I need to resolve is displaying pages of text that introduce concepts, provide learning, refer users to resources, etc. I'm probably missing a very basic control, but would I use the "label" control for displaying a lot of static text? Or, is there another (non-input) control for static text?

Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Post by acidjazz » Wed Jun 17, 2009 9:06 pm

Yup, the Label Field is generally the way to go for text, although it's surprising the different ways you can get text to show up. But, this is the most straight forward.

- Mark

Post Reply