
Quote from emo on December 5, 2023, 10:51 amI have the following code:
CreateEmptyArray [poi]
CreateEmptyArray [poi.latitude]
CreateEmptyArray [poi.length]
CreateEmptyArray [poi.url]
beginjs
// operations with a Json
// and at a given moment I need to pass variables from js to neoscript
$App.poi.latitude(0)=latitude;
$App.poi.length(0)=length;
$App.poi.url(0)=poiUrl;
endjs
It works with normal variables, but what is the format when the variable is an array?
thank you!
I have the following code:
CreateEmptyArray [poi]
CreateEmptyArray [poi.latitude]
CreateEmptyArray [poi.length]
CreateEmptyArray [poi.url]
beginjs
// operations with a Json
// and at a given moment I need to pass variables from js to neoscript
$App.poi.latitude(0)=latitude;
$App.poi.length(0)=length;
$App.poi.url(0)=poiUrl;
endjs
It works with normal variables, but what is the format when the variable is an array?
thank you!

Quote from luishp on December 5, 2023, 12:09 pm@emmanuel-fernandez this is the correct syntax in JavaScript:
CreateEmptyObject [poi] beginjs latitude = 20; longitude= 10; poiUrl = "https://google.es"; $App.poi.latitude=latitude; $App.poi.length=length; $App.poi.url=poiUrl; endjs jsAlert [poi.url]
@emmanuel-fernandez this is the correct syntax in JavaScript:
CreateEmptyObject [poi] beginjs latitude = 20; longitude= 10; poiUrl = "https://google.es"; $App.poi.latitude=latitude; $App.poi.length=length; $App.poi.url=poiUrl; endjs jsAlert [poi.url]

Quote from luishp on December 5, 2023, 12:17 pmOr, if you want poi to be an Array of objects and store a collection of latitudes, etc.:
CreateEmptyArray [poi] CreateEmptyObject [poi(0)] BeginJS latitude = 20; longitude= 10; poiUrl = "https://google.es"; $App.poi[0].latitude=latitude; $App.poi[0].length=length; $App.poi[0].url=poiUrl; EndJS jsAlert [poi(0).url]
Or, if you want poi to be an Array of objects and store a collection of latitudes, etc.:
CreateEmptyArray [poi] CreateEmptyObject [poi(0)] BeginJS latitude = 20; longitude= 10; poiUrl = "https://google.es"; $App.poi[0].latitude=latitude; $App.poi[0].length=length; $App.poi[0].url=poiUrl; EndJS jsAlert [poi(0).url]

Quote from emo on December 5, 2023, 2:07 pmOk, thanks @luishp, the second example is closer to what I want, even so, the variables are increasing in the javascript code, so I need them to be created in new objects.
This only works for object(0)CreateEmptyArray [poi] CreateEmptyObject [poi(0)] BeginJS //read a file with a json in each line and gets latitud, longitud y poiUrl. //los asigana a poi(0) $App.poi[0].latitud=latitud; $App.poi[0].longitud=longitud; $App.poi[0].url=poiUrl; //fin de bucle EndJS jsAlert [poi(0).url] . lo representa en el mapa neoMapAddMarker "Container2" "" "blue" [poi(0).latitud] [poi(0).longitud] false ""but I need it for an indeterminate number of n objects...
BeginJS var n=-1 //read a file with a json in each line and gets latitud, longitud y poiUrl. //bucle n=n+1 $App.poi[n].latitud=latitud; $App.poi[n].longitud=longitud; $App.poi[n].url=poiUrl; //fin de bucle EndJS jsAlert [poi(0).url] . draw a marker in map neoMapAddMarker "Container2" "" "blue" [poi(0).latitud] [poi(0).longitud] false ""Due to my mental confusion today with objects and arrays I don't see how to do it ;.-)
Ok, thanks @luishp, the second example is closer to what I want, even so, the variables are increasing in the javascript code, so I need them to be created in new objects.
This only works for object(0)
CreateEmptyArray [poi] CreateEmptyObject [poi(0)] BeginJS //read a file with a json in each line and gets latitud, longitud y poiUrl. //los asigana a poi(0) $App.poi[0].latitud=latitud; $App.poi[0].longitud=longitud; $App.poi[0].url=poiUrl; //fin de bucle EndJS jsAlert [poi(0).url] . lo representa en el mapa neoMapAddMarker "Container2" "" "blue" [poi(0).latitud] [poi(0).longitud] false ""
but I need it for an indeterminate number of n objects...
BeginJS var n=-1 //read a file with a json in each line and gets latitud, longitud y poiUrl. //bucle n=n+1 $App.poi[n].latitud=latitud; $App.poi[n].longitud=longitud; $App.poi[n].url=poiUrl; //fin de bucle EndJS jsAlert [poi(0).url] . draw a marker in map neoMapAddMarker "Container2" "" "blue" [poi(0).latitud] [poi(0).longitud] false ""
Due to my mental confusion today with objects and arrays I don't see how to do it ;.-)

Quote from emo on December 5, 2023, 3:02 pmok, I didn't remember $scope...
$App.n=n; $scope.CreaObjetoVacio(n); $App.poi[n].latitud=latitud; $App.poi[n].longitud=longitud; $App.poi[n].url=poiUrl; $scope.pintapunto(n); where: CreaObjetovacio is a subroutine with: CreateEmptyObject [poi([n])] and: pintapunto is a subroutine with: neoMapAddMarker "Container2" "" "blue" [poi([n]).latitud] [poi([n]).longitud] false ""
ok, I didn't remember $scope...
$App.n=n; $scope.CreaObjetoVacio(n); $App.poi[n].latitud=latitud; $App.poi[n].longitud=longitud; $App.poi[n].url=poiUrl; $scope.pintapunto(n); where: CreaObjetovacio is a subroutine with: CreateEmptyObject [poi([n])] and: pintapunto is a subroutine with: neoMapAddMarker "Container2" "" "blue" [poi([n]).latitud] [poi([n]).longitud] false ""