Open BLADE to a specified file using lisp

For many years I used Notepad++ to create my lisp routines. I had a command button to open Notepad++ to a file name stored in a system environment variable. No need to know why I do this but it worked well with (startapp app filename) where, of course, I defined app and filename in the tool button lisp.

Since coming over to BricsCAD last year I started using BLADE. I like BLADE and use it exclusively to write code. The problem I have is trying to create a command button for BLADE that opens a specified file. I cannot use "startapp" since BLADE is not an app. If I try (command "BLADE" filename) I get an error that "filename" is not a command. That makes sense since you can have multiple commands in one "command" call. If I use (vla-SendCommand adoc (strcat "BLADE" filenm (chr 032))) I get an error that the combined string is not a command.

I have searched for other ways to do this but have come up empty handed. Including google AI which provided a way but it did not work! Sounds familiar.

It appears to me that the BLADE command cannot accept arguments. Is there some way around this? Is there some secret character to place between BLADE and the file name? Any help would be appreciated.

Comments

  • There has in the past been some posts about sending control code to an open dcl. For Open its Ctrl+0, but any suggestions had limited effect. Will try to find.

    Have you tried a support request ? Bricscad does get back to you.

  • @ALANH

    I have not yet submitted a support request. I like to try this forum first before I bother the folks at Support. Yes, the support people have always gotten back to me within hours. Considering time zones the response is basically one day. I am happy with the support team's quick responses.

    The help document states that command "BLADE" opens an "external application window". There probably is a way to send commands to an "external application" but that is above my pay grade! Maybe some kind of Windows Shell commands.

    I looked in the registry and found a list of lisp files in the folder "VLispDbgEditor". There were no obvious registry items that looked like "file to open". I NEVER mess with the registry unless someone I trust gives me clear instructions.

  • ALANH
    edited June 22

    I was thinking the same it is in the registry wether to have a file open or is it blank. it may be as simple as a 0 for blank X for file in list of file names. Like you maybe later have a look.

    Found a couple of things in the image the (1) means use File_1. If Blade is blank then its (0).

    I am not sure though if just changing the (0) to (1) and set the filename is all you need. Part 2 of that task is using lisp to setenv. Computer\HKEY_CURRENT_USER\Software\Bricsys\BricsCAD\VLispDbgEditor\LastSession, Note Currentfile also.

    Now I have setenv somewhere.

    (vl-registry-write "Computer\\HKEY_CURRENT_USER\\Software\\Bricsys\\BricsCAD\\VLispDbgEditor\\LastSession" "Currentfile" "D:\\Acadtemp\\test2.lsp" )

    (vl-registry-write "Computer\\HKEY_CURRENT_USER\\Software\\Bricsys\\BricsCAD\\VLispDbgEditor\\LastSession" "file_1" "D:\\Acadtemp\\test2.lsp" )

    (vl-registry-write "Computer\\HKEY_CURRENT_USER\\Software\\Bricsys\\BricsCAD\\VLispDbgEditor\\LastSession" "NumFiles " "0x00000001(1)" )

    Its not working as I think it should as I don't have the correct admin rights need to set that, there are permissions in the regedit tried changing them but they did not change. A bit more homework needed and need help setting (1). Manually changed file name ok.

  • I submitted a support request. I expect the answer will be "No, you cannot send a file name with the BLADE command."

    This is not a big deal with me since there are several very simple work-arounds. I just got used to having the ability with Notepad++ and was trying to switch my workflow to BLADE. Can't always do what you want!

    As far as the registry is concerned it would be nice if I could add my saved filename into the "LastSession" file list if it is not already listed. Then when opening BLADE the file would be there like the other previous files. I simply do not have enough knowledge of the inner workings of the "LastSession" folder to start adding files.

    A curious thing: "vl-registry-write" is listed in the V25 Developer's Reference but is not in V26. The other vl-registry… functions are also missing. There are, however, a lot of registry functions in DOSLib.

  • ALANH
    edited June 22

    Ok it worked, using the vl-reg I opened blade and opened last lsp used as say file1, when you look at then registry it will have the 0x00000(1) so just change the file1 and currentfile name to be what you want. When you open Blade it should now be correct file. It only works if you set last file number to match.

    I tried vl-registry-read but does not seem to work can then find the file number in "NumFiles"

    (vl-registry-read "Computer\HKEY_CURRENT_USER\Software\Bricsys\BricsCAD\VLispDbgEditor\LastSession" "file_2")

  • @ALANH:

    Try

    (vl-registry-read "HKEY_CURRENT_USER\\Software\\Bricsys\\BricsCAD\\VLispDbgEditor\\LastSession" "file_2")

  • I stand corrected! V26 Developer's Guide does list the vl-registry commands.

    I got a response from Virgil at Bricsys. He confirmed the BLADE command does not accept arguments. He provided a link to AutoHotKey. I have not yet studied this approach. I would have to learn a new coding language and setups etc. A shortcut-key will be my second choice if I can't get the registry approach to work correctly.

    http://email.bricsys.com/c/eJw8jc2unCAYQJ_mYyfRD38XLIa2rpo0mUkfgMGPylSFAmp9-5vJTe7unM05k7QNioGRrLoeEeu669ksOzS26UrqqWwHOwg9VLpD29Zdb7VpLHOyKnHoG9EOyKtWtIJ_BbpalFCXIfppN9n5rXh6XRwrN_wZnUlXKhLFwxlKxXZwt2WKm17YIuecQwJxAxwBx_M8ud6zn33-Sxc3fgUcJ28S4Hgg4Oi2if7zOa9s1W4p3CSLikX5ohgvqEvraFooJr4SS_vzRSZLwAb7xx1RVKJ5ywCoHnsIPmZAFenfTumTwnIBqgJQ_Qq0ue0PoFI_b99_AKrT5RlQpUDGvTeAyrqFOMvycf-2p-xXir_DpDOxQ-JHAAAA__8gNW_Y

    As suggested by @martin@enco.us the text "Computer" is not needed. The example code in the Developer's Guide does not show "Computer" in the string.

    Later today I will try to incorporate registry code suggested/tested by @ALANH into my routine. I have a few questions about using this method and will have to resolve them by trial and error. One question is what happens if my file name is already in the registry list, say as "file_2" and I put the same file into "file_1'. I have no idea what BLADE will do until I try it.

    Thank you all for your help.

  • The key issue in my earlier post is using \\ instead of \ as a separator in the string. If I recall correctly a single \ is read as an escape character, not a \ path separator.

  • @martin@enco.us

    Sorry I misread your post. I am so used to seeing the double back slash I was not paying attention. The examples in the Developer's Guide do use \\.

  • Jerry I did what you asked had the same file name for file1 and file2 and it worked. Just need to say make sure file1 is always the current file before existing blade. Save do not close files as that will set the Binary flag to (0)

  • @ALANH

    Today I learned that the vl-reg-write command will create a REG_RZ value if you provide a string and it will create a double real REG_DWORD if you provide a number. Therefore when setting numfiles input a 1 instead of a string. That correction made my routine work. Numfiles is the number of files that were open when you closed BLADE and shutdown Bricscad. I believe the values are saved to the registry only after shutdown cad.

    So when you restart cad and open BLADE the previous files will be opened. Right now with numfiles set to 1 and my saved file in file_1 just that file appears. Therefore we lost the previous status of BLADE. I will correct this later tomorrow by reading numfile adding 1 and writing my file into file_n. I may have to check to make sure my file is not already in the first n files in the list. Should be straight forward.

    Alan, your test with two files with the same name worked because you used numfiles set to 1 so I think the rest of the list is ignored. Thank you for putting so much effort into my project.

  • It was an interesting challenge. I think if you make a little C: defun and have say your lisps in a support path or preferred directory then can enter a simple name like Test.lsp as its full directory can be found. For me normally only have two directories for most work. So 2 defuns. (strcat path filename)