A propos google sheet

Bonjour Mr STEVE
Toujours a propos votre réponse du 31 décembre 2019
Sétif c’est une ville
c’est pour ça je veux lorsque je serai a Sétif comme exemple, si je clique sur un bouton il utilise les numéros qui concerne la ville Sétif
est ce que je mets tout les numéros de Setif dans une seule feuille de Google Sheet avec les numéros de Samu de Constantine
et j’utilise la condition if

Hello Mr STEVE
Always about your answer of December 31, 2019 ( https://groups.google.com/forum/#!profile/mitappinventortest/APn2wQczmfY_o0S-jHctktJUh8Ile3DMoEfis0xHsTOe5degUUtjaTjn59biQT6_O_D6NTkrpsTt/mitappinventortest/t0vwzNXe48s/q-PZTbykAwAJ )
Setif is a city
that’s why I want when I am in Sétif as an example, if I click on a button it uses the numbers which concern the city Sétif
do I put all the numbers of Setif in a single sheet of Google Sheet with the numbers of Samu de Constantine
and I use the if condition

There are several possible ways you can determine the setif Samira.

1) A simple way to determine where the Android is located is to use information from the LocationSensor CurrentAddress block.

a) Use the LocationSensor CurrentAddress block to determine where your Android device is located .

Use the setif information from the CurrentAddress to determine which spreadsheet to use for the phone information. Make a different GoogleSpreadsheet for each setif.

For example, if the setif Constantine is in the CurrentAddress, then use the setif spreadsheet you made for Constantine to access the phone numbers.

An easy possible way to determine the setif is code similar to these Blocks

The example is hard coded to check to see if the CurrentAddress is in Constantine setif. You can confirm that this works by making a simple app using the LocationSensor and try the code using the name of the setif you are in. Does this work?

Alternatively, you can parse the CurrentAddress block to extract the setif information.

This method is simple. It only requires you use the LocationSensor component.

b) If the spreadsheet you make contains setif names, you might be able to use a single spreadsheet with the phone numbers for all the setif you need. This method is more complicated. Use sql like commands to retrieve the appropriate phone numbers from the spreadsheet and the CurrentAddress block information.

2) A very complicated way to do something similar is use a json file of all the 48 administrative districts and a Map component . To display the wilayas on your Map; load the json as a FeatureCollection. You need a LocationSensor; a Map component and a FeatureCollection. From coordinate information, Blocks can determine which of the 48 districts (wilayas (provinces) ) the Android is located in.

Use the information from the wilayas (provinces) to determine which spreadsheet to use for the phone information. Make a different GoogleSpreadsheet for each setif.

For example, if the Android is located in Constantine wilaya (province) , then use the setif spreadsheet you made for Constantine to access the phone numbers. This method will only tell you the wilaya, not the setif.

I would use the first method.

What have you tried?

You might find this tutorial HOW TO: Parse a LocationSensor's Current Address by SteveJG helpful.


Bonjour mr Steve
pourquoi j’ai cette erreur lorsque je clique sur le premier bouton gendarmererieCapture21

Hello mr steve
why i got this error when i click on the first gendarmererie button

I certainly do not know Samira. What the problem might be cannot be determined unless you post the code in le premier bouton gendarmererie . You probably use a select list item
Block incorrectly. Possibly your List is not populated at the time you press the button. You can use a DoIt on the Block that represents the List and see what it contains (see Taifun’s tip #4 here https://puravidaapps.com/learn.php ).

Please post the code you tried but does not work.

Bonjour Mr Steve
voici le code et la feuille de calcul



I can not understand what you are trying to do. Maybe someone else can.

From the images it appears you are doing many things wrong. The result is chaos. You are attempting to do some complex things when you do not need to do them. Keep your code simple until you get it to work. Later, do exciting things. In other words, do not try to do everything at once.

What I guess is causing problems based on what I think I understand:

In Capture34, where is your when Web1.GotText Block. Use the GotText to set responseContent to download the spreadsheet as a csv?

Then, perhaps, populate the List you call global phoneNumbers ??? using the listfromcsvtable responseContent ?

You probably should place your Web1.Get block inside the If …connected block.

In Capture33 for each item in list can not be used to make the phone call. Simply set PhoneCall1.Phone number to 1055 and then call PhoneCall1.MakePhoneCall ; when you use the GenBtn

initialize global phoneNumberList to make a List join 1055 is not generating a LIST. Use DoIt to find out what is actually in phoneNumberList.

I expect doing this improperly is why you get the Runtime error message; there is nothing in phoneNumberList ir something that is not a List.

In Capture35 you set a Procedure called setNumber. This might work depending on what is contained in global buttons … you do not show how you make the global buttons List

I suggest you start over. Code the part to retrieve the phone numbers from your spreadsheet (download a csv and convert it to a List) Use only a single Screen. Using multiple screens is more difficult to code and adds a layer of complexity that is unnecessary. Once you get the phone numbers working as a List; add three Buttons to call each of the spreadsheet items using simple logic…place this code


in each button event handler where you the index is variously 2, 3 or 4 depending on the button. I am not testing the code, so I can only guess it will work. Try it.

Good luck.

Samira_kh Did you solve your coding issues yet Samira?

This is the Screen from the simple app you should code before doing all the complicated things you would like to do using the TinyDB and other things with your spreadsheet. Select your spreadsheet using information from CurrentAddress . Download the spreadsheet csv appropriate to that city. Convert the csv to a List. Use the List to select the data you need to make the phone call using the Buttons. Is this what you want to do? When this basic app works, you are ready to make the more complicated app.

Let us know how your coding progresses.

Bonjour Mr Steve
je veux ces trois numéros existent dans la feuille de google sheet et je veux lorsque j’ appuyer sur le bouton gendarmerie, police ou pompier me fait l’appel directement de la feuille google sheet s’il y a une connexion internet.
si quelqu’un n’a pas de connexion internet il peut aussi appeler ces numéros
comment faire
et je ne veux pas afficher la feuille de google sheet sur écran

You said “I want these three numbers exist in the google sheet and I want when I press the button gendarmerie, police or firefighter makes me the call directly from the google sheet if there is an internet connection.
if someone has no internet connection they can also call these numbers
how to do
and I don’t want to display the google sheet on screen

A example showing how to do part of what you want to do in your app is shown in this tutorial Retrieve location specific Phone Numbers (or other data) from an appropriate Google Spreadsheet Samira.

Get this example working with your information and spreadsheets. Then, think about a way to provide default phone numbers using a TinyDB. What you hope to do is complicated. I suggest you create your app in stages. Get part of the app to work correctly before you try to do the complex part.

You do not have to " ne veux pas afficher la feuille de google sheet sur écran"
Once this works, create the code so that you can code if someone has no internet connection they can also call these numbers*
how to do
and I don’t want to display the google sheet on screen"

Do one part of the app at a time. :slight_smile:

– Steve

Bonjour Mr Steve
les numéros de téléphone pour gendarmerie, police et pompier sont les mème dans toute les wilaya de l’Algérie donc on a besoin a une seule feuille de Google Sheet
mais lorsque je clique sur le bouton gendarmerie pour faire l’appel il me donne ce message d’erreur ( Attempt to get item number 2 of a list of length 0: () )
voici votre bloc

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps

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

I don’t know. Either DoIt as Taifun suggests or consider that the app example you refer to is designed to work with several GoogleSpreadsheets . It assumes the phone numbers are different in each wilaya or city. In the case where the phone numbers are always the same, you do not need a GoogleSpreadsheet for your app.

I suspect you get the error because your Web1.GotText does not return a 200 value responseCode. If a 200 is not received, the IF statement after the else in the Web.GotText sets the contents of the theCSV variable to an empty string (it sets it to an empty string when the responseCode received is not 200 so the else statement calls the clearVariablesAndLabels Procedure).

In Button3, you have a coding error indicated because you did not initialize SpreadsheetID1 (see below for a solution)

*1 the SpreadsheetID to should be set to an empty text block initially.

*2 what you placed in SpreadsheetID should be placed instead in SpreadsheetID1 and SpreadsheetID2 If you want to use the example with a single sheet follow the instructions in the tutorial for using one sheet to test the app, that is set SpreadsheeID1 and ID2 to the same sheet, then adapt the blocks to the way you want the app to work…

*3 the global theCSV is initially set to an empty text block in the example. You set it to a csv table. That should be OK. If you attempt a Web Get and the result is not 200, the code sets theCSV to an empty string. You can fix that behavior by not setting theCSV to an empty value in the clearVariablesAndLabels Procedure .

There may be other issues. Try fixing *1 and *2 and then attempt to access your spreadsheet. Prior to pressing Button3, are you waiting long enough for the LocationSensor to get a CurrentAddress ?

Here is a comparison of what YOU coded and the example:


The image shows some recommended changes that may get the app to work the way you want it to.

Good luck. Let us know what happens when you make changes.