how to let Livecode run json in proper format

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
darkshadow
Posts: 4
Joined: Sun Jul 21, 2013 10:18 am

how to let Livecode run json in proper format

Post by darkshadow » Mon Jul 22, 2013 4:24 pm

Hello everyone:
I'm just learned some fundamental knowledge of livecode, and recently got a project to do, but i'm really confuse in how to change the code below in proper format, in other words, like the general survey format we usually in the web (like the first picture) and display it in livecode.
Any suggestions?
Attachments
survey.png
survey.png (1.82 KiB) Viewed 11159 times
code.png

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to let Livecode run json in proper format

Post by Simon » Mon Jul 22, 2013 8:04 pm

Hi tkytky,
Either you've changed your name or this same job was given to you.
In any case this exact question was asked before:
http://forums.runrev.com/phpBB2/viewtop ... =9&t=16024
If you ask specific questions regarding implementation of specific aspects I'd be happy to help.

Now have you gone through the lessons?
http://lessons.runrev.com/
The scripting conference?
http://www.hyperactivesw.com/revscriptc ... ences.html

Have you read or browsed the User Guide (resources icon)?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

darkshadow
Posts: 4
Joined: Sun Jul 21, 2013 10:18 am

Re: how to let Livecode run json in proper format

Post by darkshadow » Tue Jul 23, 2013 2:06 am

Hi Simon:
Thank you very much for your reply.
I'm not sure which one of the plugin file i should use.
Also, the tutorial in the livecode web has few thing about json, i only got json to array file from it.But it seems haven't too much help.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to let Livecode run json in proper format

Post by Simon » Tue Jul 23, 2013 5:52 am

Hi tkytky,
There is not a "button" or "plugin" you can use to get what you would like. You will have to code this yourself.
There are no LC samples or examples that turn the info you are getting into a form.
Do you understand this?

The parsing is easy (for some of us) and creating the form as well.
Try, and if it's not working post your code here.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: how to let Livecode run json in proper format

Post by TKYTKY » Tue Jul 23, 2013 5:58 am

Hi simon and darkshadow

By the way darkshadow wasnt me. But i guess darkshadow got the same problem as me .

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to let Livecode run json in proper format

Post by Simon » Tue Jul 23, 2013 6:01 am

Not only the same problem but the same jason code.

Hey.. do you think it's your competitor?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: how to let Livecode run json in proper format

Post by TKYTKY » Tue Jul 23, 2013 6:05 am

I think we are doing on the same project and can`t get things going.
Btw simon do you have skype ?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to let Livecode run json in proper format

Post by Simon » Tue Jul 23, 2013 6:09 am

Yes I do, but Dave (dave_probertGA6e24 ) is good.
Maybe a bit acidic but I'm hoping a good guy.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: how to let Livecode run json in proper format

Post by TKYTKY » Tue Jul 23, 2013 6:14 am

Cause you been helping me since i posted my question. so i think you got an ideas what i m suppose to do.
I`m not sure about dave.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to let Livecode run json in proper format

Post by Simon » Tue Jul 23, 2013 6:16 am

Dave, step up to the plate.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: how to let Livecode run json in proper format

Post by TKYTKY » Tue Jul 23, 2013 6:20 am

Can you give me more clues about radio button and stuffs? i tried the last coding you gave me. Successfully separate those question apart. but i aint sure about the radio button

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: how to let Livecode run json in proper format

Post by dave_probertGA6e24 » Tue Jul 23, 2013 10:29 am

Thanks Simon - I was hoping to hide from this one :) Ph-Neutral is what I aim for though ;)

Darkshadow / TKYTKY,

Not too sure I can help here, but I can try.

To summarise - you have a JSON output from some source (either file or generated), you need to create livecode cards with each of the questions on it along with the A,B,C radio choices.

To load the JSON I can recommend the JSON Library by the late Mark Smith. You might have to search to find a copy though. There should be links on the forum or Revonline.

Once you have run the data through the parser you should then have an array or arrays contain a structured version of the JSON file.

You should then iterate through the appropriate array parts and use the 'create' command in LC to make a new 'field' or 'button', put the text into the new object and then position it (depending on the device you are targeting).

Radio buttons should be created inside a group so that they know that they should work together.

Handling the responses from the 'form' is usually based on a 'button' script which will then look at the radio group to get the answer and move on to the next screen.

Most of this is pretty obvious in terms of functionality. The fine detail of exactly how you want to do this is really up to you and the requirements of your overall task. There is no 'standard' tool to create and handle a form - because everyone's needs are different.

If you have looked at each of the lessons regarding creating components, using groups, and working with radio buttons then it's only a case of combining that knowledge via understanding and coding ability.

If you need more help then it would be best to post a few examples of the JSON formatted questions, and a picture of the required output and if someone is being really nice and has some spare time they might create an example stack for you.

Cheers,
Dave
(I hope my Milk intake was enough to reduce any Acidity ;) )
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: how to let Livecode run json in proper format

Post by FourthWorld » Tue Jul 23, 2013 2:54 pm

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to let Livecode run json in proper format

Post by Simon » Thu Jul 25, 2013 12:50 am

OK guilt got the better of me because I said I'd help if paid and he did offer. (just too small a job)
attached is the stack from Mark Smith modified for TKYTKY.
Mark did all the hard work I just present the info.

This will probably generate more questions.

Simon
Attachments
TKYTKY.zip
LC 6.1
(11.76 KiB) Downloaded 331 times
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply