This Item Does Not Exist - Using a Method In A Web App

Hi All,

I’ve started playing with Xojo and have hit a wall with my first Web App.

I’ve created a UUID Method based on something I’ve found elsewhere.

It looks something like this:

[code] Dim db As New SQLiteDatabase
dim uuid as string
If db.Connect Then
uuid= db.SQLSelect("select hex( randomblob(4)) " _
+ "|| ‘-’ || hex( randomblob(2)) " _
+ "|| ‘-’ || ‘4’ || substr( hex( randomblob(2)), 2) " _
+ "|| ‘-’ || substr(‘AB89’, 1 + (abs(random()) % 4) , 1) " _
+ "|| substr(hex(randomblob(2)), 2) " _
+ “|| ‘-’ || hex(randomblob(6)) AS GUID”).Field(“GUID”)
uuid = “ERROR”
End If

return uuid[/code]

Then I put Method(UUID) this into the code for a button’s action

dim d as new Modal1 dim s as string s=UUID '<<Error here D.Label1.Text = s D.Show

I get an error “This Item Does Not Exist” UUID

Am I doing something wrong? Is there an equivalent of a “Static” Method?

What’s the name and scope of your method? And where did you put it (meaning: Is it part of a class, a window, a module …?)
If your UUID method is part of a different object than the button, you need to call it by its full location - say you put it into your app module, then you would have to call it like

s = app.UUID
The method code is only for explanation, not the real one, I guess? Otherwise it wouldn’t work as long as you don’t assign an existing database file to db.

EDIT: By “static” method you mean a global one? You can have such if you put a method into a module and set its scope to global.

@Ulrich Bogun Thank you! I had a feeling it was something simple like that. The Method is contained under the App. I’m still learning scoping features in Xojo…

Actually, that code does work to generate a UUID.

Xes, by “static”, I mean global. The UUID method was set to Global :slight_smile:

You’re very welcome, Chad! Glad I could help!

Yes, scopes may be a bit difficult at first. But it’s not that complicated: Basically each method, property etc. belongs to the object you put it in, so you need to address it with its full namespace. You can only do so from the outside – meaning from somewhere else than from within the object – if its scope is public. Protected means you can only address it from within the class object itself and its subclasses, and private objects can only be addresses from within the object.

Exception to this rule are modules which you can use to add functionality to existing Xojo classes or to define global properties and methods. If you set a modules’ object or method scope to global, you can use it from everywhere only by its name. Protected in modules means you have to use the module namespace to use it, and private is of course useful for internal things that shouldn’t be available outside the module.