Thank you so much Erel

Mashiane

Expert
Licensed User
Longtime User
Wow

I just had my first opportunity to check this "As" casting stuff. OMG! this is so powerful!

Looking at..

B4X:
 var doc_id = xmlDoc.getElementsByTagName("kml")[0].getElementsByTagName("Document")[0].id;
 var doc_name = xmlDoc.getElementsByTagName("kml")[0].getElementsByTagName("name")[0].childNodes[0].nodeValue;

So I tried to implement it in my sub here...

B4X:
Sub UploadKMLFile(fileObj As Map)
    'get the file details
    Dim fileDet As FileObject
    fileDet = BANanoShared.GetFileDetails(fileObj)
    'get the file name
    Dim fn As String = fileDet.FileName
    fn = fn.tolowercase
    'only process kml files
    If fn.EndsWith(".kml") = False Then Return
    'read the file contents as text
    Dim kmlText As String = BANano.Await(vuetify.GetFileAsText(fileObj))
    'convert to xml Doc
    'var xmlDoc = (new DOMParser()).parseFromString(text, 'text/xml');
    Dim domParser As BANanoObject
    domParser.Initialize2("DOMParser", Null)
    Dim xmlDoc As BANanoObject = domParser.RunMethod("parseFromString", Array(kmlText, "text/xml"))
    'read the docID and docName
    Dim kmlList As List = xmlDoc.RunMethod("getElementsByTagName", "kml")
    Dim doc_id As String = kmlList.Get(0).As(BANanoObject).RunMethod("getElementsByTagName", "Document").As(List).Get(0).As(Map).Get("id")
    Log(doc_id)
    Dim childNodes As List = kmlList.Get(0).As(BANanoObject).RunMethod("getElementsByTagName", "name").As(List).Get(0).As(BANanoObject).GetField("childNodes").As(List)
    Dim doc_name As String = childNodes.Get(0).As(BANanoObject).GetField("textContent").Result
    Log(doc_name)
End Sub

Off course, you need to understand exactly what you are trying to achieve.

Its such a breath of fresh air also that this works so seemlessly with BANano.

Awesome stuff guys!

Mashy ???
 

Magma

Expert
Licensed User
Longtime User

LucaMs

Expert
Licensed User
Longtime User
Well I hope this... some time... work in real life...

Zastava.As(Porsche)
Seat.As(Ferrari)
Water.As(Gasoline)
Rocks.As(Food)
Sand.As(Water)
Sh*t.As(Money)
...

Sorry guys, this list never ends...
Well, "someone" made the following transformation a couple of millennia before Erel:

Water.As(Wine)

(evidently everyone was alcoholic in those days ? )
 

Magma

Expert
Licensed User
Longtime User

jmon

Well-Known Member
Licensed User
Longtime User
Well I hope this... some time... work in real life...

Zastava.As(Porsche)
Seat.As(Ferrari)
Water.As(Gasoline)
Rocks.As(Food)
Sand.As(Water)
Sh*t.As(Money)
...

Sorry guys, this list never ends...
It makes me think about some superstition in Thailand. People put stickers on their car, writing what color they think their color should be

I.e.: "This car is black", "this car is cream color".... Etc...

More info in English here
Since buying a new vehicle is not an option for everyone, the Thai put a sticker saying “This car is red,” or whatever color, on their car, believing that it can neutralize the jinx of the inauspicious tone.

I think we need that for superstitious people:
B4X:
FX.colors.red.As(FX.colors.green)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…