"load" command?

All flavors welcome.
Forum rules
Be kind.
Post Reply
mwieder
Posts: 136
Joined: Sun Jun 04, 2023 3:32 am
Location: Berkeley, CA, US, Earth
Contact:

"load" command?

Post 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).
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: "load" command?

Post 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 ]
mwieder
Posts: 136
Joined: Sun Jun 04, 2023 3:32 am
Location: Berkeley, CA, US, Earth
Contact:

Re: "load" command?

Post 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.
FourthWorld
Posts: 442
Joined: Sat Sep 11, 2021 4:37 pm
Contact:

Re: "load" command?

Post 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?
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: "load" command?

Post 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.
mwieder
Posts: 136
Joined: Sun Jun 04, 2023 3:32 am
Location: Berkeley, CA, US, Earth
Contact:

Re: "load" command?

Post 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.
User avatar
richmond62
Posts: 4833
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: "load" command?

Post by richmond62 »

what the dictionary says
Dunno how often I'd rely on that! :lol:
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: "load" command?

Post 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.
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: "load" command?

Post 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.
mwieder
Posts: 136
Joined: Sun Jun 04, 2023 3:32 am
Location: Berkeley, CA, US, Earth
Contact:

Re: "load" command?

Post 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.
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: "load" command?

Post 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.
FourthWorld
Posts: 442
Joined: Sat Sep 11, 2021 4:37 pm
Contact:

Re: "load" command?

Post 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?
mwieder
Posts: 136
Joined: Sun Jun 04, 2023 3:32 am
Location: Berkeley, CA, US, Earth
Contact:

Re: "load" command?

Post by mwieder »

No, seems to be happy with https:// urls. Just not file://
FourthWorld
Posts: 442
Joined: Sat Sep 11, 2021 4:37 pm
Contact:

Re: "load" command?

Post 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?
mwieder
Posts: 136
Joined: Sun Jun 04, 2023 3:32 am
Location: Berkeley, CA, US, Earth
Contact:

Re: "load" command?

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests