Author Topic: CSED & command line to program  (Read 5038 times)

0 Members and 1 Guest are viewing this topic.

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
CSED & command line to program
« on: February 04, 2012, 04:04:06 PM »
Hello,

I'm having problems with CSed running a program & supplying a command line.
I typed in a simple command line of 1 word and have tried the various run options
but none of them are passing the command line.

Simple sample program is below.

What am I doing wrong?  It does work outside of CSed running from the command prompt.
Running under XP.

Code: [Select]
#DIM ALL
#COMPILE EXE
%UNICODE = 1

' // Include files for external files
#INCLUDE ONCE "CWindow.inc"     ' // CWindow class

' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, BYVAL lpszCmdLine AS WSTRINGZ PTR, BYVAL nCmdShow AS LONG) AS LONG
   local wcmd as wstring
   local cmd as string
   
   wcmd = @lpszCmdLine
   cmd = wcmd
   msgbox "wcmd =" & wcmd
   showit cmd

END FUNCTION
' ========================================================================================
sub showit(x as string)
   msgbox "string cmd >" & x
end sub

« Last Edit: February 04, 2012, 04:06:03 PM by Paul Elliott »

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: CSED & command line to program
« Reply #1 on: February 04, 2012, 04:33:09 PM »
Indeed. It will happen the same with any other editor. Try it with the PB IDE if you want. The command line is passed by the operating system to the program when you run it from the command prompt.

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: CSED & command line to program
« Reply #2 on: February 04, 2012, 04:43:20 PM »
I don't understand.

If I Set Command Line in PB v10 Editor to a simple word and compile/run then the
program gets that word.

But not in CSED.  In searching the CSED source I can only see 1 occurance of
pSed.CommandLine ( in csed.bas where it gets set ).


Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: CSED & command line to program
« Reply #3 on: February 04, 2012, 05:20:30 PM »
Ah! That command line. Sorry, I was thinking in another thing.
Go to Menu-->Run-->Command Line

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: CSED & command line to program
« Reply #4 on: February 04, 2012, 05:24:19 PM »
That's what I'm talking about.  I can not get it to pass that info to the program it just compiled.

Maybe it takes a later version of Windows than XP. But I can only find 1 occurance of
pSed.CommandLine in the cSED v1.03 source files. And that is just setting the value.
It is never used.

Did you try compiling & running the sample code?


Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: CSED & command line to program
« Reply #5 on: February 04, 2012, 05:51:03 PM »
Yes, but I'm using version 1.04, not yet released. This is one of the several small changes that I have done to this new version.

Looking at the code of the file CSED_COMPILE.INC (lines 710-712) you can see:

Code: [Select]
                           strCommand = strExeFile
'                              IF LEN(g_strCommandLine) THEN strCommand = strCommand & " " & g_strCommandLine
                           r = SHELL(strCommand, 1)

In the new version it has been replaced by:

Code: [Select]
                           strCommand = strExeFile
                           IF LEN(pSed.CommandLine) THEN strCommand = strCommand & " " & pSed.CommandLine
                           r = SHELL(strCommand, 1)
« Last Edit: February 04, 2012, 05:55:55 PM by José Roca »

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: CSED & command line to program
« Reply #6 on: February 04, 2012, 06:14:20 PM »
Jose,

Thanks. That works.