!!!HELP!!!! USING PHP OR HTML IN A FUNCTION!!!!

I need help with this when I use a script on its own work well but if i start the same script in a function it does´t work any more.

the script is:

[lua]local function mapping (event)
for i=1, #markerTable do
markerCode[i] = [[

var infowindow]]…i…[[ = new google.maps.InfoWindow({
content: “]]…markerTable[i].name…[[
]]…markerTable[i].notes…[[”
});

var marker]]…i…[[ = new google.maps.Marker({
position: new google.maps.LatLng(]]…markerTable[i].lat…’, '…markerTable[i].lon…[[),
map: map,
animation: google.maps.Animation.DROP,
});

google.maps.event.addListener(marker]]…i…[[, ‘click’, function() {
infowindow]]…i…[[.open(map,marker]]…i…[[);
});

]]
end

local markerString = table.concat(markerCode)


–HTML & JAVASCRIPT CODE

local mapString = [[

[html]


html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }

[/html]
]]

local htmlFile = io.open( path, “w” )
htmlFile:write( mapString )
io.close( htmlFile )

native.showWebPopup (0, 75, display.contentWidth, 790, “map.html”,{baseUrl=system.DocumentsDirectory})
end[/lua]

I NEED HELP WHY DOES´T IT WORK!

THe Terminal always says that there is an error:

attempt to concatenate field ‘notes’ (a nil value)

thanks for any reply

Lenny [import]uid: 149464 topic_id: 30546 reply_id: 330546[/import]

Hi Lenny,

The error is that the field ‘notes’ is nil, so presumably it’s referring to line 6 if your code. In your code snippet above, you haven’t actually defined markerTable anywhere, which meqans markerTable[i].notes is in fact nil, which would explain the error.

  • Andrew [import]uid: 109711 topic_id: 30546 reply_id: 122367[/import]

I have defined markerTable outside of the function but maybe the network request isn’t done so the markerTable is nil at the moment when its called. I only was confused because he told me that the error is in the line where the ]] is. But you say that the skript would work if markerTable is defined? [import]uid: 149464 topic_id: 30546 reply_id: 122412[/import]

Now I made one table in the markerTable so that he haven´t to wait for the network request and now i get an error in line 170 and this lines is

[lua] ]][/lua]

so the problem isn´t solved with this and all tables are defined before the function.

Lenny [import]uid: 149464 topic_id: 30546 reply_id: 122416[/import]

Hi Lenny,

What is the actual error message you receive? Also, you mentioned line 170 – which line does that correspond to in your code snippet above (the line numbering is different)?

  • Andrew [import]uid: 109711 topic_id: 30546 reply_id: 122426[/import]

The error is the same as above

attempt to concatenate field ‘notes’ (a nil value)

the line 170 is the line 1 which i postet to show where the error is located

the error at the script a the front of the page is located in line 20 and 61

Lenny [import]uid: 149464 topic_id: 30546 reply_id: 122429[/import]

Hi Lenny,

If lua is giving you the error that the field notes is nil, then unfortunately it must be (whether you think it is or not). The error is probably generating for line 20 in your snippet above, because that’s where the multi-line string ends, but the actual problem is the reference to markerTable[i].notes in line 6.

To check this, immediately after your [lua]for[/lua] starts, try inserting the line [lua]print(markerTable[i].notes)[/lua]. In the terminal window, if you see it printing “nil”, then you know that markerTable[i].notes is in fact nil, which explains the error.

  • Andrew [import]uid: 109711 topic_id: 30546 reply_id: 122762[/import]

Hi Lenny,

The error is that the field ‘notes’ is nil, so presumably it’s referring to line 6 if your code. In your code snippet above, you haven’t actually defined markerTable anywhere, which meqans markerTable[i].notes is in fact nil, which would explain the error.

  • Andrew [import]uid: 109711 topic_id: 30546 reply_id: 122367[/import]

I have defined markerTable outside of the function but maybe the network request isn’t done so the markerTable is nil at the moment when its called. I only was confused because he told me that the error is in the line where the ]] is. But you say that the skript would work if markerTable is defined? [import]uid: 149464 topic_id: 30546 reply_id: 122412[/import]

Now I made one table in the markerTable so that he haven´t to wait for the network request and now i get an error in line 170 and this lines is

[lua] ]][/lua]

so the problem isn´t solved with this and all tables are defined before the function.

Lenny [import]uid: 149464 topic_id: 30546 reply_id: 122416[/import]

Hi Lenny,

What is the actual error message you receive? Also, you mentioned line 170 – which line does that correspond to in your code snippet above (the line numbering is different)?

  • Andrew [import]uid: 109711 topic_id: 30546 reply_id: 122426[/import]

The error is the same as above

attempt to concatenate field ‘notes’ (a nil value)

the line 170 is the line 1 which i postet to show where the error is located

the error at the script a the front of the page is located in line 20 and 61

Lenny [import]uid: 149464 topic_id: 30546 reply_id: 122429[/import]

Hi Lenny,

If lua is giving you the error that the field notes is nil, then unfortunately it must be (whether you think it is or not). The error is probably generating for line 20 in your snippet above, because that’s where the multi-line string ends, but the actual problem is the reference to markerTable[i].notes in line 6.

To check this, immediately after your [lua]for[/lua] starts, try inserting the line [lua]print(markerTable[i].notes)[/lua]. In the terminal window, if you see it printing “nil”, then you know that markerTable[i].notes is in fact nil, which explains the error.

  • Andrew [import]uid: 109711 topic_id: 30546 reply_id: 122762[/import]