Hide Command Prompt Window when RUN Batch file

Hi Mike

this is getting a bit silly.

sure your code code has three clips.

but I try to avoid clips so I wouldn’t do that.

as mentioned previously an advantage of something like ST is that you do away with arbitrary lengths.

in your case your full name might be 41 chars but you have set an arbitrary length of 32 which is too small so you have a bug where larger names are truncated. ST protects you from making such an error as it expands as necessary. You don’t need to be able to add up.

OK so you can easily fix it to be 41 chars - but what if later the cus:LastName and cus:FirstName are increased from 20 to say 30. You would need to again adjust the arbitrary size of fullname, whereas ST would just take it in its stride.

In your ST example the final clip is unnecessary as firstname is already clipped.

If you compare apples with apples the number of clips are identical. In the first example with one clip the fullname is unclipped.

similarly saying

st.setvalue(clip(lastname) &' '& firstname)

would only have one clip and the string as a whole would be unclipped.

or you could do two clips either

st.setvalue(clip(lastname) &' '& clip(firstname))

or

st.setvalue(clip(lastname) &' '& firstname,st:clip)

then say you wanted to add an address on the end after the name - the ST string is already clipped whereas you would need to clip your fullname in the first example - so two clips each.

Sure you can live without ST - in fact everyone did so for many years. But if it saves you making bugs and generally makes you more productive why wouldn’t you use it? I mean just because we could write all our code in assembler rather than Clarion doesn’t make it a good idea.

anyway I think enough of this - I’m not sure if my enthusiastic proselytizing has caused you offence but if so I apologize.

Hi Dave, I also used PowerRun back in the day. Personally I would not suggest you share it without first contacting Greg Burthume to get his permission. Others may have a different opinion if it is “abandonware”.

That was my thought.
Can’t be a hypocrite, right?

https://web.archive.org/web/20200201073021/http://www.berthume.com/powerrun.htm

I don’t think that sharing it in this case would be a problem. Normally I agree with you.

I was talking about static methods
Clarion doesn’t have a formal static method like other languages.

Let me define a static method as a method that does not require an instance of the class that it belongs to.

Which in practice means any method that does NOT dereference properties either directly - or indirectly by calling other methods in the class which in turn use a property

Your program can pass a NULL self-parameter and your program will work UNLESS you try to dereference a property - in which case you’ll crash.

Looking at StringTheory, I see that the StringTheory.Trace is overloaded, neither of which is a static method as they both eventually use SELF.Value OTOH StringPicture.Trace can be considered a static method.

I’d like to see the ability to add ,STATIC to a method prototype
which would cause the compiler to complain if you deference a property or use SELF or PARENT to call another method which does not also have the ,STATIC attribute.

I view this as being like CONST where the compiler will complain if you alter the value of a parameter that was passed by value (and marked as CONST)


The following code will compile and work
The advantages are:

  • no memory is allocated for the properties
  • no call to .Construct
  • no call to .Destruct

The disadvantage is

  • given the lack of a formal static notation in CW:
    a change to the class might lead to a crash
Static:SP &StringPicture
   CODE
   Static:SP.Trace('my message')

thanks Jeff I didn’t realise it had been made free.

there is a download link on that page that downloads what looks to be the PowerRun install (I thought its name “setuppr” was strange but realised it stood for Set up PowerRun)

OK thanks for the explanation

I think if you use st.trace(‘some message’) then it is essentially the same as the StringPicture.trace and it will not use self.value. (Self.value is only used where the optional passed message string is excluded or blank).

By chance the earlier

declaration that I mentioned gets you “part way” to what you seem to be after. It does do the construct and destruct however only once per thread - construct at the beginning of the thread and destruct at the end. It is obviously different in that it has all the properties but these are not automatically reset and hence persist between invocations of the containing code structure (procedure for example). Hence definitely NOT the same thing as static methods but heading in that general direction.

Hi Mark,

You can end up with paths that are longer than FILE:MaxFilePath. I usually use CSTRING(1025) for paths.

See:

https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/

Hi Mark
Your gist example has introduced a memory leak, by changing szParm and szPath to reference cstrings the RETURN at line 158 comes before the 2 x DISPOSE statements.
Julian.

@Julian Thanks for this, I have updated the gist.

Mark

Mark an <Omitted String> if called by SIZE() will return Zero bytes.

That way you could have simpler code that avoids the NEW() and DISPOSE() by just declaring them CSTRING( Size(inXxx) + 2 ):

I would still check for OMITTED() before doing the assignment:

  IF NOT OMITTED(inStartPath) THEN szPath   = CLIP(inStartPath).
  IF NOT OMITTED(inParams)    THEN szParams = CLIP(inParams).

You should change szFilename CSTRING(Size(inFilename)+1)
to be (Size() +3 ) because if the FIle Name contains spaces you wrap it in “Quotes” which adds 2 bytes.

 szFilename = CLIP(inFilename)
 IF INSTRING(' ',szFilename,1,1) AND szFilename[1] <> '"'
    szFilename = '"' & szFilename & '"'
 END

I do wonder if quotes are required for the EX version of ShellExecute. Probably should test it. Maybe only needed if the File name contains a \Path. Does the Start Path also need to be quoted if it contains spaces?

Powerrun at last was freeware.

Wx code, but you can port it easy to Clarion: API(“shell32.dll”,“ShellExecuteA”,0, 0, &sBatFile,0, 0, 0) // → Hide

// SW_HIDE = 0
// SW_MAXIMIZE = 3
// SW_MINIMIZE = 6
// SW_RESTORE = 9
// SW_SHOW = 5
// SW_SHOWDEFAULT = 10
// SW_SHOWMINIMIZED = 2
// SW_SHOWMININOACTIVE = 7
// SW_SHOWNA = 8
// SW_SHOWNOACTIVATE = 4
// SW_SHOWNORMAL = 1