I have a console utility that needs to deal with ascii files (because of other programs/scripts that will be supplying those files or reading them afterwards). The console output may also be redirected to an existing ascii log file. So, it seems sensible to supply #PB_Ascii in the Mode parameter of OpenConsole().
But, Mode is the second parameter - the first being Title$. I don't want to alter the existing title of the console I'll be running inside - I want to leave the existing title unchanged.
Both Mode and Title$ are optional parameters, but I don't see a way to provide Mode without first providing Title$. Is there a special value I can pass for the title that keeps the existing value or some other syntax to provide a value for a later optional parameter without having to pass a value for the earlier ones?
PB clearly knows how to leave the title as-is, because that's what happens with plain OpenConsole(), no parameters provided. I don't see a PB native way to read the existing title to restore it either (and even if there was, I would probably have to call OpenConsole() first, at which point I'm too late - the existing title has been overwritten).
Any suggestions? Am I missing something obvious?
OpenConsole() with mode but no title?
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: OpenConsole() with mode but no title?
Workaround for Windows:
Code: Select all
EnableExplicit
Define ConsoleTitle$ = Space(1024)
If OpenConsole()
GetConsoleTitle_(@ConsoleTitle$, 1024)
CloseConsole()
EndIf
If OpenConsole(ConsoleTitle$, #PB_Ascii)
Input()
CloseConsole()
EndIf
Re: OpenConsole() with mode but no title?
That looks like it might do the trick - thanks.
I assume I'm right though in that there is no way in PB to supply a later optional parameter without also supplying the earlier optional ones? Bit of a rare case, but it would be useful sometimes.
I assume I'm right though in that there is no way in PB to supply a later optional parameter without also supplying the earlier optional ones? Bit of a rare case, but it would be useful sometimes.
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: OpenConsole() with mode but no title?
Yes, that's not possible.mikejs wrote:I assume I'm right though in that there is no way in PB to supply a later optional parameter without also supplying the earlier optional ones? Bit of a rare case, but it would be useful sometimes.
This is possible in other programming languages. Example:
Code: Select all
MyFunction(Parameter1, , , Parameter4)
A wish thread already exists: viewtopic.php?f=3&t=60551
Nobody knows when this syntax function will be implemented.