SideDiff & 17/01/21 ROM
Julie Stamp (8365) 474 posts |
Well that went well :-/ A better fix for this issue could be to alias
as is done in the SideDiff !Boot. |
Stuart Swales (1481) 351 posts |
Yes, if FD1 is to be handled that way. I’ve always just stamped text BASIC files with FFB. Sorry about that. What happens when you try to actually fix things, eh? All those programs waiting to fail when they get a command line longer than BASIC’s string limit… |
Timothy Baldwin (184) 242 posts |
And hopefully this should fix the ancient OS_EvaluateExpression bug. |
Steve Pampling (1551) 8170 posts |
So a golden-oldie dies (yay!) |
Steve Pampling (1551) 8170 posts |
Ah, you mean like the method of causing Transient/TrapDelete to crash? Sorry Fred – discovered that this weekend and forgot to mail a bug report. |
Rick Murray (539) 13840 posts |
Trying to access a file with a path over ~230 characters crashes the filer. That’s why my software assumes filenames/paths won’t be more than 255 characters in length – it’s more than the Wimp can handle, so more than you’d get via a Wimp Message. |
Steve Fryatt (216) 2105 posts |
It does. But a command line could legitimately be
where each of those is ~230 characters long. I believe that’s supported in modern RISC OS versions. However, whilst
will promptly fall over,
(FSVO You can then get them by
and nothing exceeds the 255 characters allowed by BASIC. |
Steve Pampling (1551) 8170 posts |
Actually the Filer stayed operational – presumably Transient did a life-saving intervention. Its selfless sacrifice is noted. |
Fred Graute (114) 645 posts |
That’s okay Steve, this should be easy to replicate. To save me some experimentation, how long was that filename? |
Stuart Swales (1481) 351 posts |
Exactly that Steve F. |
Steve Pampling (1551) 8170 posts |
Ah, now you’re asking… It was something I created when playing around with the longest filenames Word will produce, copied it to RPCEmu and checked what RO would make of it. I think it was about 213 – 236 characters – with spaces of course because Word is brain-dead and breaks titles at punctuation rather than whitespace. 236 is the Word maximum, I think you need to bring that string down to about 213-ish to make RO display it in the filer. I, currently can’t replicate – I think the current beta ROM may be affecting some functions in Transient. Due to start work in 8 minutes. |
Steve Drain (222) 1620 posts |
Allow me a little reminiscence. In the early days I would decode a command line using the search for " or the offset methods. I saw OS_ReadArgs, but put it to one side as too complex to bother with. When I was writing Basalt a couple of decades ago I thought it would be a good idea to incorporate its facility into BASIC, so I learned how to use it in detail. This resulted in:
where
There’s the rub. If you have several filenames of indeterminant length, how do you know what size of buffer to create, especially as it is only temporary? I always use the 16K ‘scratch space’ at &4000. ;-) |
Rick Murray (539) 13840 posts |
That question is perhaps best answered by asking how you receive the filenames. For me, a buffer of ~256 will suffice because you can’t get more sent via a Wimp Message (DataLoad). ;-) |
Steve Drain (222) 1620 posts |
It was pointed out in the parallel topic that a command line can contain many filenames. ;-) |
GavinWraith (26) 1563 posts |
RISC OS uses fixed length buffers for everything. I guess it seemed simplest at the time, but even in those days plenty was known about more sophisticated datatypes. Perhaps the constraint was the price of memory rather than the complexity of garbage collection? If one was starting afresh the design of an OS, surely one of its components would be a memory manager that would enable not only programming languages but also command shells to rid themselves entirely of having to make guesses about the sizes of files or the lengths of commands? For real-time programming I can see that this might present a problem; the OS would also need a policy to protect itself from rogue tasks with inordinate demands. But that should not be made the concern of everyday user-tasks. I have spent so much time with RiscLua, and away from BASIC, that questions about the lengths of strings seem as old-fashioned as theological disputations. |
Rick Murray (539) 13840 posts |
That’s probably what many felt for simple single-parameter extraction. For more complicated stuff, yes, it makes sense. Have you taken a look at ChangeFSI? I wonder if ReadArgs could cope with that?
I’m surprised ReadArgs doesn’t.
Read what I wrote carefully, especially the part mentioning the DataLoad message. ;-) To be honest, I wonder how likely we are to actually encounter files with names/paths adding up to more than ~236 bytes, given the inherent limitations in the Desktop? I can imagine such files pretty much being pathological cases intended to not work as expected (if at all) outside of the command line. Likewise, one shouldn’t really be making use of a command line of more than 256 characters unless they know they’re on a system that is capable. The…. I’ve forgotten the name, thing that comes with the DDE to give long command lines… is an alternative that works on all current systems, but it’s a little bit fiddlier.
It would be nice, but you’re always going to run into programmers doing stuff like char filename[11]; // 10 plus terminator ;-)
The problem with this is that making strings ‘smart’ is a slippery slope to hell. I don’t know Lua, but I know what you mean about strings because php works a bit like that. But it tries too hard. Let me ask you, is “1” the same as 1? The answer is “maybe”. If you add “1” and “1”, is the result “11” or “2”? You can run into some interesting buglets upon discovering that your “simple string assignment” was interpreted by php in a way that defies logic. BTW, it’s not just BASIC with string lengths. C does it too. And to a degree I prefer it like that. I’m old school, I like to know that I should allocate ‘x’ bytes for something that is ‘x’ bytes in length. The problem is, the RISC OS API hasn’t kept up with the underlying changes. Filenames can now be ‘x’ bytes in length. The ROOL guys don’t want to pin down any specific length out of fear that people might start hardcoding such limits, though Jeffrey hinted that the limits weren’t really limits likely to be hit, so Steve’s using 16K of scratch space “just in case” might have some merit. Plus, we can’t blindly allocate sixteen thousand bits for all filenames – if we did that we’d end up with memory consumption to rival Android apps. |
GavinWraith (26) 1563 posts |
Agreed. Wimp_LoadTemplate is a good example.
In the current RiscLua, no. In the early days of Lua, there were all sorts of coercions, string <-> number, integers <-> floats, in the belief that this made things easier for users. Slowly the attitude has swung the other way; coercions are being understood to be a source of error. They are turned off by default in RiscLua. You should use explicit so that the expression
has the intended value, then you simply precede your code with the statement
|
Steve Fryatt (216) 2105 posts |
We’re not talking about single filenames, though, are we? When you need to know the command line in a BASIC program, you call OS_GetEnv, which returns the command which launched the program. The reason that we’re doing this parsing stuff at all is that it isn’t just the arguments that you’ll get back. First you’ve got
which launched BASIC to run the program. Then you’ve got the parameter which told BASIC where your program itself was
It’s only after that lot is out of the way that we get to the parameters that the user actually entered. So if the command was
the actual command line returned by OS_GetEnv is
It makes far more sense to accept that the OS will allow what it allows in terms of command line length, and the let OS_ReadArgs worry about breaking that lot up into
than to arbitrarily truncate the whole lot at 255 characters whatever the system can handle. Sure, older systems won’t cope with long names, but newer ones will, and will therefore enable any of the filenames to be up to the system maximum of ~230 characters. |
Steve Drain (222) 1620 posts |
Use
It is important to grasp this. My Crunchie might have 6 filenames and many switches. ;-) |
Alan Adams (2486) 1149 posts |
I recently needed to issue a lot of More on-topic, I’ve just done a quick check of my set of programs, and so far found just one looking for a quote character in the result of OS_Env. It does this to find the start of the path to the program in order to locate other things. One effect of this is that that particular program doesn’t work if run from StrongED (using the run button in the window). The environment string in that case is strange. |
Stuart Swales (1481) 351 posts |
Nice, but *commands aren’t always the answer – may I refer you to https://www.riscosopen.org/wiki/documentation/show/OS_FSControl%2026 |
Steve Drain (222) 1620 posts |
This can also be obtained using OS_ReadArgs. Programs run using the filetype alias will always be -quit and for me that is what I expect. So I use the -quit as a keyword for the program name, which is then the string at
It is run from memory using addresses, I think. I have changed my mode file to always save and then run from disc. |
Alan Adams (2486) 1149 posts |
So I tried OS-ReadArgs. I don’t understand the error message:
|
Richard Coleman (3190) 54 posts |
That’s because you’re asking for a single parameter named “quit” but input$ contains 3 parameters, one of which it will recognise as a switch (-quit). |
Richard Coleman (3190) 54 posts |
Oh, and the string will be terminated with a zero so $(wlib_block%!8) wont work, so use SYS “XOS_GenerateError”,wlib_block!8 TO A$ |