• Welcome to PlanetSquires Forums.
 

command line problem

Started by raymw, September 23, 2021, 09:38:21 PM

Previous topic - Next topic

raymw

Hi, Hope everyone is OK, been quiet here, but I've been doing other stuff, as I guess you have,too.  I'm trying to write a simple gui, to collect together various parameters and then run it as a command line. Here is the line in question

openscad.exe -o c:\users\ray\desktop\openscad\test.echo --export-format echo c:\users\ray\desktop\openscad\measure.scad

If i open a cmd window (using w10) and cd to the directory where openscad.exe resides, I can paste the line and it does what it should. However, I can't seem to get it to work from using run/exec/chain whatever directly from the basic program, or the compiled program placed in that same directory (or anywhere else). Any help appreciated.

Johan Klassen

have you tried changing to that directory before the call ? https://www.freebasic.net/wiki/KeyPgChdir

raymw

Thanks, I think I tried that. I seem to have tried everything, but in the end I've solved it in a kludgy way, by making the fb code write a batch file, and then getting it to run that. Of course, the w10 virus checker gets bothersome at times, and half the time it won't let me put files where I want to. Still all working now.

raymw

Can anyone remind me how to set the tab order? I thought there was a list box sort of thing that you could position the items on, or was that in firefly? Associated problem, maybe, - I use a label to display information, which appears when a button is hovered over (show/hide). I have two such labels/buttons, both created at the same time in the designer. However for one, the label appears as I expect, for the other, more or less in the same position, it does not show on top of all the main window items, some of the underlying items show through, so to speak. In the designer, if position one item over another, it is difficult to select each one, one will be shown on top of the other, and the bottom boundaries/selection is next to impossible. I guess I could use 'tool tip' instead, but I wanted to use the hide/show label.

philbar

#4
Use the TabIndex property in the toolbox for each control. It works pretty much the way you expect. If you promote a control, say from 5 to 2, then 2, 3, and 4 will be shifted down. If you demote a control, say from 3 to 6, then 4, 5, and 6 will be shifted up.

In the designer, if one thing is covering another, you can use TAB/SHIFT-TAB to highlight controls in the tab order sequence.

Getting back to the original question, there has been some talk about that over in the FB forum over the years. The problem is that CHAIN/RUN/EXEC don't use the execution path list; you have to specify the full path of the called program. SHELL does use the path variable, but it creates an annoying command prompt to do it. Fxm offered a simple function Execute(program, options) that reads the PATH variable and tries EXEC on each path in the list until one of them works. As far as I can tell, if you need control over whether the calling program waits for the callee to finish or continues independently, you'll have to learn to use CreateProcess, which I find daunting.

raymw

Thanks. I found the tab index after I posted before, but it was not where I expected it to be (of course I was looking under the properties for 'labels' (who in there right mind wants to be able to tab around labels?  ;) )) Having, over the last couple of years been messing with other languages, it took a while to recall how things are done here - I still keep using // for comments, and have to stop putting ; at he end of lines. I was going to write this little project in Python, - it seems to be the fashion - but having looked into trying to do basic gui stuff, I decided to use winfbe. but it is a steep re-learning curve. I spend a lot of time looking for functions that do not exist. I thought there was an inbult function to do a text replace, a sort of mid/instr combination (probably exists in c#) but I found this succinct piece of code that does it.

function replace(byref txt as string, byref fnd as string, byref rep as string) as string
   
    dim as string txt2 = txt
    dim as integer fndlen = len(fnd), replen = len(rep)
   
    dim as integer i = instr(txt2, fnd)
   
    while i
       
        txt2 = left(txt2, i - 1) & rep & mid(txt2, i + fndlen)
        i = instr(i + replen, txt2, fnd)
       
    wend
   
    return txt2
   
end function


going back to my original question, I wrote a batch file
fo=freefile
    open "runscadtemp.bat" for output as #fo
    print #fo, "cd "+ppo
    print #fo,ate
    close #fo

where 'ppo' is thew full path to the program and 'ate' is the command line  and then that batch file was used as required by chain ("runscadtemp.bat")

Now to decide if it is worth trying to use markdown code within the 'echo' text.

José Roca

> I spend a lot of time looking for functions that do not exist. I thought there was an inbult function to do a text replace, [...]

There are four replace functions in the WinFbx headers: AfxStrReplace, AfxStrReplaceI, AfxStrReplaceAny and AfxStrReplaceAnyI.

See: https://github.com/JoseRoca/WinFBX/blob/master/docs/String%20Management/String%20Procedures.md#AfxStrReplace

raymw

Hi Jose,

Thanks, I was having a struggle with basic free basic, heaven knows the fun I'd have with winfbx. Of course, I'd forgotten there was a help file in the winfbe editor...