Newbie question - what's the code behind?

Hello,
I discovered AI2 a few days ago, I followed the first tutorials, and I still have some to follow :slight_smile:
I am not a programming specialist but a speech therapist who likes to build programs for my patients. I used to work with macromedia authorware in the past but this software is dead ... and the actual time is about mobile apps instead of exe for computers :wink:
In AI2, I recognize some features I found so usefull fin AW7 for the non-specialist I am (variables, reference to an external file, loops, if-then etc.). But I do have questions too, and I must admit that I do not find the doc section about this topic.

My first general question is : is it possible to code the variables, if-then, readextfile etc as lines of code, or do we have to do it with the puzzle pieces of the graphic interface ? I guess, that what we build in the blocks interface is converted in real code : do we have access to it ?

I hope to be understandable :wink: and can't wait to go on with further tutos (unfortunately I have job to do and real patients to see, so I can't spend my whole time geeking on that site !!)

I will take every info you will give, I am curious and have so much to learn yet !
Have a nice week-end :slight_smile:

if you wanna get the contents of a file then use file component -

thanks for having taken time for an answer ; maybe my question wasn't clear enough.

I give you an example of what I meant, this is what I used to do in AW7 :

The following example extracts the list of words to practice from a external textfile (one item = one line), counts the number of items included in that list (= number of lines), and randomly picks one.
(liste_mots, nb_mots, n and mot_cible are variables ; ReadExtFile, LineCount, Random and GetFile are functions)

--extraction du fichier d'items
liste_mots := ReadExtFile("liste.txt")
nb_mots := LineCount(liste_mots)

--extraction de l'item
n := Random(1;nb_mots;1)
mot_cible := GetLine(liste_mots;n)

I find it easier to program typing it than assembling blocks ... but maybe I'm wrong :wink:
How can I do this in AI2 ?

thx again

Write everything in English (don't mix French and English) and show us an understandable concrete example.

See also here:

no, you have to use the blocks

use the file component as already mentioned and convert the file into a list, just use the split block and split at \n (new line)
http://ai2.appinventor.mit.edu/reference/blocks/text.html#split
to extract a random item use the pick a random item block
http://ai2.appinventor.mit.edu/reference/blocks/lists.html#pickrandomitem

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

Thank you Taifun,
Your answers are precisely what I was looking for :

  • now I know that I can't type but I must use the blocks
  • you gave me hints about how to solve this precise issue
  • I know what to read to learn more about AI2
    ... and of course I will go on with tutorials : I have to say that they are incredibly pedagogic, it's really a good way to learn !

Have a good day everyone :slight_smile:
Hélène

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.