Toolbox_GetSysInfo directory return slightly different from PRM
|
I’ve just found that in RISC OS 5 the Toolbox_GetSysInfo call to get a the application directory returns the directory specified in Toolbox_Initialise with a dot appended rather than as the it was passed as is implied in the documentation. RISC OS 4.0.2 returned “<App$Dir>” as I expected. I’ve looked at the ROOL code and can see it was done to support passing of a path to Toolbox_Initialise (about 12 years ago) and so I’m not proposing it needs to be changed, I just thought I’d mention it in case it trips someone else up. I found it as I was launching my help from the code of an application and it failed on the Raspberry Pi. I used Filer_Run <App$Dir>.!Help which with the extra dot became Filer_Run <App$Dir>..!Help which is why it failed. I’m sure this was working on my Iyonix though – anyone any idea why? Alan |
|
Yes, previously if you passed in a directory you got back a directory. Internally now everything is being held as a path, so if you pass in a directory or a path you always get a path back. However, I’m not sure I follow how this situation has cropped up in your program. To paraphrase in psuedo code: SYS"Toolbox_Initialise", "<MyApp$Dir>" SYS"Toolbox_GetSysInfo", GET_DIRNAME TO dir$ SYS"OSCLI", "Filer_Run "+dir$+"!Help" since this is all in the confines of your program, and <MyApp$Dir> is known outside the scope of your program (by the OS), why not just change the last one to say SYS"OSCLI", "Filer_Run <MyApp$Dir>.!Help" |
|
I didn’t do it directly as it is in a library used by multiple toolbox applications that added a generic show_help command. It needed a way to figure out what help to show. I know I could have added the app dir name to the command, but it didn’t seem necessary as there was a simple way to get it from the toolbox. |
|
Ah, I see, that makes sense. It’s an easy one to fix in the Toolbox module, but as you note there’s ~10 years of modules out there with the extra dot, you’d need to RMENSURE the appropriate fixed version (the toolbox modules pop out in the !System download for pre RISC OS 5 users). Alternatively RMENSURE the oldest version that supports paths, pass in a path, and run MyAppPath:!Help perhaps? |
|
Depending which way you want to go:
I did not know of this until this topic. Basalt has a DIR$ function, so I will have to do a similar check there to make things conform to the UIT manual again. |
|
I had already done the equivalent of the second of Steve’s suggestions to make the result from any version of the toolbox consistent and work with Path variables or directories.
The main reason for this post was in case anyone else may bump into the same problem, so I’m glad you found it! |