Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MMBasic for DOS. Ver 5.04 Beta
Page 6 of 6 | |||||
Author | Message | ||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3661 |
That would cause problems in various scenarios (such as when the .bas is in another user's account or a read-only location). Every process gets a current working directory (*) so normally uses whatever it got. (*) from a shell, commands such as pwd show it; and you can change it such as by cd A typical way to override this (in the cases where that is wanted) is to provide a short cut (shell script / Windows link / etc) which sets the working dir to wherever you want and then invokes the executable. John |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2290 |
that would be fine if the current directory was set consistently the same. how about the following compromise: OPTION LOCAL when invoked, the current directory is set to the direcrory that the dropped .bas file is located in. for those folks who want the current directory set to an unexpected location not of their choosing, they can leave it out. for those folks who want to be able to access files located in the same directory as their basic program, place OPTION LOCAL at the beginning of their code. cheers, rob :-) |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3661 |
Instead, why not set it up as the OS allows? In Windows you can set it in any of a few ways e.g. in a shortcut. In Linux you can at worst use a tiny shell script but I suppose the GUIs also allow it. (I've never needed to do it and probably never will.) No need to mess with MMBasic. John |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2290 |
that is excellent advice. would you mind posting an exhaustive list of how to do this on each of the versions of windows, and taking into account the numerous ways in which user accounts may be set up on each version? really do appreciate your help on this one. cheers, rob :-) |
||||
flip Senior Member Joined: 18/07/2016 Location: AustraliaPosts: 114 |
Hi Geoff, I think I found a new bug in recent release with ON ERROR SKIP not working...or more likely maybe its the fact that MM.ERRNO and MM.ERRMSG$ is not being reset to zero after a successful command. DIM AS STRING MASTER_DB="MasterDB.MMD" SUB INIT LOCAL AS INTEGER iMMERR LOCAL AS STRING sMMERR ON ERROR SKIP 2 CLOSE #1 OPEN MASTER_DB FOR RANDOM AS #1 iMMERR=MM.ERRNO:sMMERR=MM.ERRMSG$ SELECT CASE iMMERR CASE 0: ? "Opened OK" CASE ELSE: ? "Failed to open ";MASTER_DB;": ";sMMERR;"(Err#";iMMERR;")" END END SELECT END SUB INIT prints Failed to open MasterDB.MMD: File number is not open(Err# 16) The problem is that its returning the message for the first failed command after the SKIP 2, even though the Second command after the SKIP 2 was successful. Before, (with same code) it reset error to 0 on the second command after the SKIP 2 Regards, Phil |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3661 |
Since about 1985 you can right click on the desktop and create a shortcut, putting in the info. If you want to do it from an installer, read up on the MS web site. For more details they provide a great wealth of info for developers. However, most do not consult it... (And some expect others to do that for them.) John |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2290 |
If you want to do it from an installer, read up on the MS web site. For more details they provide a great wealth of info for developers. However, most do not consult it... (And some expect others to do that for them.) John while a shortcut allows you to set the current directory to a fixed location, it does not allow it to be set to the directory containing the .bas file (as happens when a file association is used). i have been reading through the microsoft developer site quite extensively. however, the following 'helper' application does the trick, delphi source included: 2017-07-25_112603_drop_here.zip place 'drop here.exe' in the same directory as mmbasic.exe and your .bas files. if you drop a .bas file onto the 'drop here' icon, mmbasic will be launched with the .bas file passed as a parameter and the current directory set correctly. it makes use of a couple of functions from the win32 API: GetFullPathName is used to fully expand the path to the .bas file, this then has the filename trimmed off, and the result is passed to SetCurrentDirectory to set the current directory to the correct place (where the .bas file resides). while i make use of CreateProcess to launch mmbasic.exe, i don't use it to set the current directory as that would hide the 'fix' in a non-obvious place. the end result is the same as if a file extension association had been set up. cheers, rob :-) |
||||
Page 6 of 6 |
Print this page |