Author Topic: Code-Formatter PB 10  (Read 158592 times)

0 Members and 1 Guest are viewing this topic.

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #75 on: November 19, 2011, 11:21:36 PM »
Hi Paul,

Quote
See my posts #52 & #54.  I had tried the code there but it didn't get executed.
Plus the code you put there doesn't match what Phoenix says should be there.
So I removed the excess code.

The code is not superfluous, he is bulged whom a file is passed in the command. Then the dialogue should not be executed


Quote
Still more strangeness.
In the InitApplication,
if %UNICODE is defined you get the command line but the program then ends right there.
if %UNICODE NOT defined  you get only the 1st char & file not found & program ends.

You currently do not you allowed to use Unicode, since Phoenix is not able to cope. Only when the program is fully programmed. Then strings are XSTRING, and all through ASCIZ XASCIZ functions replaced in Phoenix, then it goes again

Quote
In CopyBak doing a date/time stamp you don't allow for "/" in date. Also the program ends
after making the copy.

'll Try that again yesterday, it has gone


regards Peter






« Last Edit: November 19, 2011, 11:36:32 PM by Peter Weis »

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 10
« Reply #76 on: November 19, 2011, 11:40:56 PM »
Peter,

Have you tested getting a command line? The routine as written isn't right for ASCII data.
Some comments as to why that extra code was in there would have helped.

What does Phoenix have to do with this? This is PB code and should be UNICODE safe.
I thought you handled the ASCII/UNICODE parts with your macros?
Or will you have to wait for Phoenix v3 before the program will work?

Just curious as I keep hitting a brick wall on getting things to work.
It's time to quit for the nite ( been up since 3am ). Be back sometime tomorrow.


Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #77 on: November 19, 2011, 11:49:56 PM »
Hi Paul,
you do not have to wait until 3.0 comes out of Phoenix, just until I'm finished with the IDE, then I write about the parameters. One can then no longer go with Phoenix tuned!

regards Peter

Offline Dominic Mitchell

  • Jr. Member
  • **
  • Posts: 64
  • User-Rate: +11/-5
    • Prometheus Software
Re: Code-Formatter PB 10
« Reply #78 on: November 20, 2011, 12:02:19 AM »
Phoenix 2.0 does not support unicode.
Phoenix 3.0 does.
Dominic Mitchell
Phoenix Visual Designer
http://www.phnxthunder.com

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #79 on: November 20, 2011, 12:31:27 AM »
Hi Dominic,

I know that Phoenix does not support Unicode 2.0. Hold me, but with macros but above water and then go Unicode!

regards Peter

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #80 on: November 20, 2011, 08:13:51 AM »
Hi Paul,
 I changed the variables in CodeFormatter_InitApplication type so that command goes!
 Command is always the case PowerBASIC 10 WSTRINGZ PTR

Code: [Select]
FUNCTION CodeFormatter_InitApplication _
  ( _
  BYVAL hInstance AS DWORD, _ ' handle of current instance
  BYVAL lParam    AS LONG _   ' address of command line
  ) AS LONG

  LOCAL lpszcmdline AS WSTRINGZ PTR                     '20.11.2011 Muss Bei PowerBasic 10 WStringz Ptr
  LOCAL filenum AS LONG
  LOCAL ztext , zOut AS XASCIZ * %MAX_PATH
  DIM Built AS GLOBAL IPOWERTIME

  LET Built = CLASS "PowerTime"

  Built.Now()

  REDIM tabhandle(0 TO 1)

  filenum = FREEFILE
  OPEN "Code Formatter.cfg" FOR BINARY AS filenum
  GET filenum,,fo
  CLOSE filenum

  lpszcmdline =  lParam

  'check the command line for a filespec
   IF LEN(@lpszcmdline) THEN
      IF ISFILE(@lpszcmdline) THEN
         fo.fspecin = @lpszcmdline               'assumes valid source file
         fo.fspecin = fo.fspecout
      ELSE
         MessageBox 0, "File not found" + $CR + @lpszcmdline, "", %MB_ICONINFORMATION
         FUNCTION = %TRUE
         EXIT FUNCTION
      END IF
   ELSE
     FUNCTION = %FALSE
     EXIT FUNCTION
   END IF

   CopyBak

   GetTempPath %MAX_PATH, ztext
   GetTempFileName ztext, "fmt", 0, zOut ' 11/18/2011 fo.fspecout
   fc.fhin = FREEFILE
   OPEN fo.fspecin FOR INPUT ACCESS READ AS fc.fhin
   fc.fhout = FREEFILE
   OPEN zOut FOR OUTPUT AS fc.fhout
   '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   'Create a simple progress control
   '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fc.hprogress = CaptionProgressWindow(0, "Format Source Code")
   DoFormat
   CLOSE fc.fhin, fc.fhout
   DestroyWindow fc.hprogress
   CopyFile zOut, fo.fspecout, 0
   KILL zOut
   FUNCTION = %TRUE
END FUNCTION
     


 I also have a call to Form1_Btn_Format_Clicked GetOVars () are inserted so that the data is transferred from the Options fields

Code: [Select]
FUNCTION Form1_Btn_Format_Clicked _
  ( _
  BYVAL hWndParent  AS DWORD, _ ' handle of parent window
  BYVAL hWndCtrl    AS DWORD _  ' handle of control
  ) AS LONG

  LOCAL ztext AS XASCIZ * %MAX_PATH
  LOCAL zOut AS XASCIZ * %MAX_PATH
  LOCAL tmpFC AS fmtcommon
   GetOVars()  ' Get Contol vars 11/20/2011
   fc = tmpFC ' re-initialize all variables 11/18/2011

   CopyBak

   GetTempPath %MAX_PATH, ztext
   GetTempFileName ztext, "fmt", 0, zOut ' 11/18/2011 fo.fspecout
   fc.fhin = FREEFILE
   OPEN fo.fspecin FOR INPUT ACCESS READ AS fc.fhin
   fc.fhout = FREEFILE
   OPEN zOut FOR OUTPUT AS fc.fhout
   '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   'Create a simple progress control
   '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fc.hprogress = CaptionProgressWindow(0, "Format Source Code")
   DoFormat
   CLOSE fc.fhin, fc.fhout
   DestroyWindow fc.hprogress
   CopyFile zOut, fo.fspecout, 0
   KILL zOut

END FUNCTION       

regards Peter
« Last Edit: December 26, 2011, 10:40:13 AM by Peter Weis »

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 10
« Reply #81 on: November 20, 2011, 02:43:19 PM »
Peter,

Do you see anything wrong with your code below?

Code: [Select]
  IF LEN(@lpszcmdline) THEN
      IF ISFILE(@lpszcmdline) THEN
         fo.fspecin = @lpszcmdline               'assumes valid source file
         fo.fspecin = fo.fspecout
      ELSE


For whatever work I do  I'm adding #OPTION ANSIAPI and commenting %UNICODE = 1.

Frankly for general user maintenance  it would have been better to go with DDT or plain SDK.
At least anybody who might want to make changes would have all the tools needed.


Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #82 on: November 20, 2011, 04:12:36 PM »
Hi Paul,
 must be of course different. How could this happen to me
 must of course be like this!
 I have not noticed during testing because the old one was sailed in fo.fspecout stores.
 Mus course so hot
Code: [Select]
IF ISFILE(@lpszcmdline) THEN
         fo.fspecin = @lpszcmdline               'assumes valid source file
         fo.fspecout = fo.fspecin
      ELSE

 Thank you Paul

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #83 on: November 20, 2011, 04:24:20 PM »
Hi Paul,

Quote
Frankly for general user maintenance  it would have been better to go with DDT or plain SDK.
At least anybody who might want to make changes would have all the tools needed.

Perhaps it would have been better! But now Phoenix makes even the best code. And you have to make changes to only once at the end who I am done with the IDE

regards Peter

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 10
« Reply #84 on: November 20, 2011, 05:54:18 PM »
Does the commandline version force a backup? Or a date/time stamp backup?
Or does it risk overwriting a good backup produced by another program?

Maybe but the next revision to the GUI can't even be done in Phoenix according to what
you're saying. It will either have to be changed manually or ( more likely ) all ripped out and
started from scratch.

Why can't the SDK code produced by Phoenix handle UNICODE? I was under the impression
that PB is supposed to handle the conversion UNICODE <-> ANSI transparently to the
programmer.


Offline Dominic Mitchell

  • Jr. Member
  • **
  • Posts: 64
  • User-Rate: +11/-5
    • Prometheus Software
Re: Code-Formatter PB 10
« Reply #85 on: November 20, 2011, 07:04:26 PM »
The code Phoenix 2.0 generates is ANSI.
However, the code can be changed to unicode with the following modifications:

1. Define the unicode constant at this location.
Code: [Select]
' >>PHNX_END_OPTIONS

%UNICODE = 1

' >>PHNX_BEGIN_WINAPI


2. Replace All(Whole Word, Current Project) ASCIIZ to WSTRINGZ
3. Replace All(Whole Word, Current Project) STRING to WSTRING
4. If Tooltips control is used, Replace All(Whole Word, Current Project) %TTN_GETDISPINFO to %TTN_GETDISPINFOW

Steps 2, 3 and 4 will have to be done after every build.
Dominic Mitchell
Phoenix Visual Designer
http://www.phnxthunder.com

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #86 on: November 20, 2011, 07:15:44 PM »
Hi Paul,
Quote
Does the commandline version force a backup? Or a date/time stamp backup?
Or does it risk overwriting a good backup produced by another program?

You need to make you not worry because the program makes a backup with time stamp, whom it is set in the options so! You put the program to the desktop, and drag the file you formatierst via drag and drop on the code format.

Quote
Maybe but the next revision to the GUI can't even be done in Phoenix according to what
you're saying. It will either have to be changed manually or ( more likely ) all ripped out and
started from scratch.

You need only few strings through XSTRING and ASCIZ XASCIZ by replacing the only concerns the functions WinMain CodeFormatter_RegisterClasses, Form1_WndProc. The way I see it are the only three variables

Quote
Why can't the SDK code produced by Phoenix handle UNICODE? I was under the impression
that PB is supposed to handle the conversion UNICODE <-> ANSI transparently to the
programmer.

So who then is true Unicode and Unicode functions are called. Phoenix writes:
Code: [Select]
FUNCTION WinMain _
  ( _
  BYVAL hInstance     AS DWORD, _       ' handle of current instance
  BYVAL hPrevInstance AS DWORD, _       ' handle of previous instance(not used in Win32)
  BYVAL pszCmdLine    AS ASCIIZ PTR, _  ' address of command line
  BYVAL nCmdShow      AS LONG _         ' show state of window
  ) AS LONG

pszCmdLine is no ASCIZ PTR PTR but a WSTRINGZ PTR


But most times you go with the program debugger you that you see the place where the program gets out!

regards Peter

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #87 on: November 20, 2011, 07:36:07 PM »
Hi Dominic
What did you write that does not work, you can not replace all the strings by wstring, the source of the format, I still want to ANSI. You have to select exactly what is and what string wstring. You can do so only time you'll try to get hieroglyphics! >:(

Also annoying is the produce after each of the source code to find out the places that need to be changed!
Dominic is it so hard to change these views of yours? Am also pleased with Phoenix 2.0

regards Peter

Offline Dominic Mitchell

  • Jr. Member
  • **
  • Posts: 64
  • User-Rate: +11/-5
    • Prometheus Software
Re: Code-Formatter PB 10
« Reply #88 on: November 20, 2011, 08:19:02 PM »
In the case of ANSI unicode mix, the replace needs to be done only on the *.bas
and Utility.inc files generated by Phoenix.
Where can I find the files for the Code Formatter? I would like to have a look at the
location of your code relative to that generated by Phoenix.
Dominic Mitchell
Phoenix Visual Designer
http://www.phnxthunder.com

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
Re: Code-Formatter PB 10
« Reply #89 on: November 20, 2011, 08:27:39 PM »
Hallo Dominic

Here again, the code for you to put Unicode one and you will have your problems

regards Peter
« Last Edit: December 26, 2011, 10:37:22 AM by Peter Weis »