Page 1 of 1

"load" command?

Posted: Tue Dec 10, 2024 1:49 am
by mwieder
Gotten back to playing with this thing, and I came across the "load" command. It looks straightforward but doesn't seem to do anything useful. Yes, I know about "put url" and that of course works fine, but this is something else, and I'm working at the engine level so I can't just use put, I don't see any use the "load" command in the ide, so it really looks like this is some prehistoric artifact that maybe never did work properly.

Has anyone used the load command before? Any idea what it takes to get it working? The dictionary entries don't help (and don't work either).

Re: "load" command?

Posted: Tue Dec 10, 2024 2:27 am
by OpenXTalkPaul
Not sure what you're looking at in the engine source, but there's syntax for TWO different forms of the 'load' command that I know of.

The one used with revLibURL:

Code: Select all

load [URL] url [with message callbackMessage]
And the one that is for loading Extension Modules:

Code: Select all

load extension {from file filePath | from data moduleData} [ with resource path resourcePath ]

Re: "load" command?

Posted: Tue Dec 10, 2024 6:29 am
by mwieder
Right. I got that. I'm trying to use the 'load url' form to load a file, which should load the file into cache memory.
What I get is an error that the load has started but never finishes.

Re: "load" command?

Posted: Tue Dec 10, 2024 11:26 am
by FourthWorld
mwieder wrote: Tue Dec 10, 2024 6:29 am Right. I got that. I'm trying to use the 'load url' form to load a file, which should load the file into cache memory.
What I get is an error that the load has started but never finishes.
I've used load for network I/O, but not local file I/O.

strace show anything useful?

Re: "load" command?

Posted: Sat Dec 14, 2024 10:22 am
by tperry2x
You can use the load command on local files, not just network locations:

Code: Select all

on mousedown
   put "file://home/user/Documents/delivery-address.odt" into tLocalfile
   load URL tLocalfile
   put URL tLocalfile into tData
   if line 1 of tData is not empty then answer "loaded something" & return &¬
   line 1 of tdata
end mousedown
From the dictionary:
Use the load command to pre-fetch a file from the Internet in order to speed up access when using it in an expression with the URL keyword.
To use a file that has been downloaded by the load command, refer to it using the URL keyword as usual. When you request the original URL, OpenXTalk uses the cached file automatically.

Re: "load" command?

Posted: Sat Dec 14, 2024 6:56 pm
by mwieder
Yep - that's what the dictionary says.
But that has the same result if you comment the "load" command. And since the load command is not blocking, you're not necessarily giving enough time for it to complete.
Try this (and press the button a couple of times):

Code: Select all

on mousedown
   local tLocalfile
   put "file://home/user/Documents/delivery-address.odt" into tLocalfile
   load URL tLocalfile with message "loaded"
   put the result & cr after msg
end mousedown

on loaded
   put "the file is loaded into cache memory" & cr after msg
end loaded
At any rate, I've realized that the "load" command isn't really going to do what I want, so this is no longer a burning issue for me.

Re: "load" command?

Posted: Sat Dec 14, 2024 7:13 pm
by richmond62
what the dictionary says
Dunno how often I'd rely on that! :lol:

Re: "load" command?

Posted: Sat Dec 14, 2024 7:27 pm
by tperry2x
mwieder wrote: Sat Dec 14, 2024 6:56 pm Yep - that's what the dictionary says.
But that has the same result if you comment the "load" command. And since the load command is not blocking, you're not necessarily giving enough time for it to complete.
Yes, just really for illustrative purposes, just so show that the load command is used to preload either a local or remote URL in. As it's a 1kb file in this case, loaded from a local SSD, then it is fetched in time. I know what you mean though, seems to have limited use.

Re: "load" command?

Posted: Sat Dec 14, 2024 7:28 pm
by tperry2x
richmond62 wrote: Sat Dec 14, 2024 7:13 pm
what the dictionary says
Dunno how often I'd rely on that! :lol:
Just imagine, when it's sorted out though - it should actually be a useful thing to have.

Re: "load" command?

Posted: Sat Dec 14, 2024 7:44 pm
by mwieder
just so show that the load command is used to preload
Yes, but whether it actually does that or not is a question.
The fact that the load command always returns an error in the result and seems never to finish loading isn't encouraging.

Re: "load" command?

Posted: Sat Dec 14, 2024 8:01 pm
by tperry2x
mwieder wrote: Sat Dec 14, 2024 7:44 pm Yes, but whether it actually does that or not is a question.
The fact that the load command always returns an error in the result and seems never to finish loading isn't encouraging.
I think you are right. If I use:

Code: Select all

wait until URLStatus(tLocalfile) is "cached"
it'll just freeze the IDE, implying it never actually loads anything.

I stopped using all internal URL commands provided by the engine, in favour of system installed curl or wget - as they are a lot more reliable. For me at least, all the put URL / get URL commands seem to be sporadic. Sometimes they work, sometimes not.

Re: "load" command?

Posted: Sun Dec 15, 2024 4:11 am
by FourthWorld
mwieder wrote: Sat Dec 14, 2024 7:44 pm
just so show that the load command is used to preload
Yes, but whether it actually does that or not is a question.
The fact that the load command always returns an error in the result and seems never to finish loading isn't encouraging.
Does the error also occur when using the load command to download from the Internet?

Re: "load" command?

Posted: Sun Dec 15, 2024 6:36 am
by mwieder
No, seems to be happy with https:// urls. Just not file://

Re: "load" command?

Posted: Sun Dec 15, 2024 8:13 am
by FourthWorld
mwieder wrote: Sun Dec 15, 2024 6:36 am No, seems to be happy with https:// urls. Just not file://
I've never heard of this being tested with local files. It perhaps could be made to work by mapping the syntax to what happens with "put url".

But since you have "put url", what were you looking for "load url" to do differently?

Re: "load" command?

Posted: Sun Dec 15, 2024 4:55 pm
by mwieder
I'm implementing global constants so they can be defined in one file and #included. I originally thought the load mechanism would be the best way of getting a text file into memory but it turns out that's not the case anyway.