Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread Tomas Hajny
On Sat, November 3, 2018 23:04, James wrote:
> Thanks for the suggestion...
>
> I put my code in the OnCreate event as you suggested, but when I try to
> compile it, I get wrong number of parameters specified for call to
> Assign... my code worked before, and I have no idea what other parameters
> it could want or why it would be any different than my console
> application.
>
> I'm doing:
> Var
>TapFileName : AnsiString;
>TapFile  : Text;
>
> Assign(TapFile,TapFileName);

I guess that System.Assign(TapFile,TapFileName); should work for you.


> Any ideas why this works in FPC but not in Lazarus?

Probably a conflict with another Assign with a different functionality and
different syntax. I don't use Lazarus myself, but I'm sure it provides a
way to show where Assign is declared and how.

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread Luca Olivetti

El 3/11/18 a les 23:04, James ha escrit:

Thanks for the suggestion...

I put my code in the OnCreate event as you suggested, but when I try to compile 
it, I get wrong number of parameters specified for call to Assign... my code 
worked before, and I have no idea what other parameters it could want or why it 
would be any different than my console application.

I'm doing:
Var
TapFileName : AnsiString;
TapFile  : Text;

Assign(TapFile,TapFileName);

Any ideas why this works in FPC but not in Lazarus?


Because Assign is a method of the form. Use AssignFile or System.Assign.
BTW: what I explained before is *not* how a gui application is usually 
written but it should work in your case.


Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
It’s not a snippet, that’s the entire thing.   It’s pretty simple, just a 
sequential set of events to fix a file.  It would be a great help if you could 
get me an example of how to make this work.

 

James

 

From: fpc-pascal  On Behalf Of Ralf 
Quint
Sent: Saturday, November 3, 2018 5:57 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

 

On 11/3/2018 1:20 PM, James wrote:

>And you can't just pop up a dialog window without having a window/form in the 
>first place.  

That’s probably my problem…  My idea of just calling up the windows-API to get 
the save-as dialog probably won’t work without a form, even though I was able 
to get message boxes working


>In general, the logic of a GUI based program (regardless if Windows, macOS, 
>Linux, etc) simply is different from a console program. Your console program 
>main loop simply  pretty much just becomes a procedure within the GUI main 
>loop.




This logic difference is what is most confusing to me.   I just don’t know 
where to put my main program and I don’t know how to output things to some kind 
of text box.   I don’t want the user to do anything at all unless it’s 
necessary… so if everything is set up correctly, the program opens, does it’s 
thing, writes some status stuff to a text box and closes,  no buttons to push 
or anything…. If I get a GUI program to work, I guess I can put a percentage 
complete barograph somewhere.  If there’s an error, I need to stop and wait for 
acknowledgement of the error, or if the output file was not specified, I want 
the Save-As box to just open up on it’s own with out anyone pushing any 
buttons, and when the save-as box is closed the process completes on it’s own 
and the program exits without any further user intervention. 

I had that problem many years ago as well, having literally written hundreds of 
console of TUI based programs, mainly on DOS, myself. And then switching some 
of them to a GUI program in Delphi (there was no Lazarus at that time) took 
quite a bit of rethinking of  a couple of decades habits in console/command 
line ways or even self written TUI programs.



I’ve been tinkering with Lazarus, and I managed to get a form with some buttons 
based on the examples, and I did make one button open the save-as box… but I’m 
clueless on how to make the save-as box only come up when needed and by a 
programming command, not because someone pushed a button.  I still can’t figure 
out how to write my writeln’s into a text box of some sort.I get the idea… 
instead of a sequential program the executes from beginning to end,  everything 
kind of all happens at the same time

 

Yup, all the windows (as in GUI) stuff happens all the time, at the same time 
as your actual program. I have no had a program myself where I had a dialog 
"come up out of the blue" (as you kind of describe it), but I have written a 
lot of data conversion programs that at some point required to open up an 
additional open or save dialog. A lot though depends on what the actual logic 
behind the actual processing of your console program is. A lot of times, it 
might take a bit of re-organizing.
I am a bit short of time, as I am dealing on and off all day with some CERT 
stuff, but I will see that I take a closer look at that program (snippet?) that 
you posted later today or tomorrow morning  and return a rough sample of a GUI 
"solution" for it...

Ralf

 

 


 

 

Virus-free.  

 www.avast.com 

 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
Thanks for the suggestion... 

I put my code in the OnCreate event as you suggested, but when I try to compile 
it, I get wrong number of parameters specified for call to Assign... my code 
worked before, and I have no idea what other parameters it could want or why it 
would be any different than my console application.

I'm doing:
Var  
   TapFileName : AnsiString;
   TapFile  : Text;

Assign(TapFile,TapFileName);

Any ideas why this works in FPC but not in Lazarus?

James

-Original Message-
From: fpc-pascal  On Behalf Of Luca 
Olivetti
Sent: Saturday, November 3, 2018 4:47 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Windows programming tutorials for FPC

El 3/11/18 a les 21:20, James ha escrit:

> 
> I’ve been tinkering with Lazarus, and I managed to get a form with 
> some buttons based on the examples, and I did make one button open the 
> save-as box… but I’m clueless on how to make the save-as box only come 
> up when needed and by a programming command, not because someone 
> pushed a button.  I still can’t figure out how to write my writeln’s 
> into a text box of some sort.I get the idea… instead of a 
> sequential program the executes from beginning to end,  everything 
> kind of all happens at the same time


Try this:

-put a memo on the form (say, memo1) and a save dialog.
-in the object inspector double click on the OnCreate event of the form.
-this will create a FormCreate method. Put your code there (including the 
opening of the save dialog if needed).
-in your code show diagnostics messages in the memo
(mem1.lines.add('whatever'))
-at the end of your code, if everything is OK, add

 Application.ShowMainForm:=false;
 Application.Terminate;


This way, if there are no errors the form won't show, otherwise it will show 
whatever you put in the memo.

Tip: if your code will take a significant amount of time put at the beginning

Screen.Cursor:=crHourGlass;

and at the end

Screen.Cursor:=crDefault;


Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread Ralf Quint

On 11/3/2018 1:20 PM, James wrote:


>And you can't just pop up a dialog window without having a 
window/form in the first place.


That’s probably my problem…  My idea of just calling up the 
windows-API to get the save-as dialog probably won’t work without a 
form, even though I was able to get message boxes working



>In general, the logic of a GUI based program (regardless if Windows, 
macOS, Linux, etc) simply is different from a console program. Your 
console program main loop simply  pretty much just becomes a procedure 
within the GUI main loop.


This logic difference is what is most confusing to me.   I just don’t 
know where to put my main program and I don’t know how to output 
things to some kind of text box.   I don’t want the user to do 
anything at all unless it’s necessary… so if everything is set up 
correctly, the program opens, does it’s thing, writes some status 
stuff to a text box and closes,  no buttons to push or anything…. If I 
get a GUI program to work, I guess I can put a percentage complete 
barograph somewhere. If there’s an error, I need to stop and wait for 
acknowledgement of the error, or if the output file was not specified, 
I want the Save-As box to just open up on it’s own with out anyone 
pushing any buttons, and when the save-as box is closed the process 
completes on it’s own and the program exits without any further user 
intervention.


I had that problem many years ago as well, having literally written 
hundreds of console of TUI based programs, mainly on DOS, myself. And 
then switching some of them to a GUI program in Delphi (there was no 
Lazarus at that time) took quite a bit of rethinking of  a couple of 
decades habits in console/command line ways or even self written TUI 
programs.


I’ve been tinkering with Lazarus, and I managed to get a form with 
some buttons based on the examples, and I did make one button open the 
save-as box… but I’m clueless on how to make the save-as box only come 
up when needed and by a programming command, not because someone 
pushed a button.  I still can’t figure out how to write my writeln’s 
into a text box of some sort.    I get the idea… instead of a 
sequential program the executes from beginning to end,  everything 
kind of all happens at the same time



Yup, all the windows (as in GUI) stuff happens all the time, at the same 
time as your actual program. I have no had a program myself where I had 
a dialog "come up out of the blue" (as you kind of describe it), but I 
have written a lot of data conversion programs that at some point 
required to open up an additional open or save dialog. A lot though 
depends on what the actual logic behind the actual processing of your 
console program is. A lot of times, it might take a bit of re-organizing.
I am a bit short of time, as I am dealing on and off all day with some 
CERT stuff, but I will see that I take a closer look at that program 
(snippet?) that you posted later today or tomorrow morning and return a 
rough sample of a GUI "solution" for it...


Ralf




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread Luca Olivetti

El 3/11/18 a les 21:20, James ha escrit:



I’ve been tinkering with Lazarus, and I managed to get a form with some 
buttons based on the examples, and I did make one button open the 
save-as box… but I’m clueless on how to make the save-as box only come 
up when needed and by a programming command, not because someone pushed 
a button.  I still can’t figure out how to write my writeln’s into a 
text box of some sort.    I get the idea… instead of a sequential 
program the executes from beginning to end,  everything kind of all 
happens at the same time



Try this:

-put a memo on the form (say, memo1) and a save dialog.
-in the object inspector double click on the OnCreate event of the form.
-this will create a FormCreate method. Put your code there (including 
the opening of the save dialog if needed).
-in your code show diagnostics messages in the memo 
(mem1.lines.add('whatever'))

-at the end of your code, if everything is OK, add

Application.ShowMainForm:=false;
Application.Terminate;


This way, if there are no errors the form won't show, otherwise it will 
show whatever you put in the memo.


Tip: if your code will take a significant amount of time put at the 
beginning


Screen.Cursor:=crHourGlass;

and at the end

Screen.Cursor:=crDefault;


Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
>And you can't just pop up a dialog window without having a window/form in the 
>first place.  

That’s probably my problem…  My idea of just calling up the windows-API to get 
the save-as dialog probably won’t work without a form, even though I was able 
to get message boxes working


>In general, the logic of a GUI based program (regardless if Windows, macOS, 
>Linux, etc) simply is different from a console program. Your console program 
>main loop simply  pretty much just becomes a procedure within the GUI main 
>loop.



This logic difference is what is most confusing to me.   I just don’t know 
where to put my main program and I don’t know how to output things to some kind 
of text box.   I don’t want the user to do anything at all unless it’s 
necessary… so if everything is set up correctly, the program opens, does it’s 
thing, writes some status stuff to a text box and closes,  no buttons to push 
or anything…. If I get a GUI program to work, I guess I can put a percentage 
complete barograph somewhere.  If there’s an error, I need to stop and wait for 
acknowledgement of the error, or if the output file was not specified, I want 
the Save-As box to just open up on it’s own with out anyone pushing any 
buttons, and when the save-as box is closed the process completes on it’s own 
and the program exits without any further user intervention. 

I’ve been tinkering with Lazarus, and I managed to get a form with some buttons 
based on the examples, and I did make one button open the save-as box… but I’m 
clueless on how to make the save-as box only come up when needed and by a 
programming command, not because someone pushed a button.  I still can’t figure 
out how to write my writeln’s into a text box of some sort.I get the idea… 
instead of a sequential program the executes from beginning to end,  everything 
kind of all happens at the same time

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
Thanks for the gersavefilenamea idea, I have used windows API function calls 
before in my Windows Console programs, so I thought I would try to get 
getsavefilenamea or ifilesavedialog to work in my console program.  So I 
thought I would start small and get message boxes to work on my console 
program, this was actually pretty easy, I just added the windows unit to my 
program and then changed my writeln's to 
windows.messagebox(0,pchar(TapFileName+' Not Found'),pchar('Error'),MB_OK);

And poof I get a message box when I encounter the error, and the program waits 
until I hit OK to continue.  Neat!  

 

So it's looking promising, that perhaps I can just keep it a console program 
that launches the save-as dialog somehow when needed.This idea appeals to 
me for several reasons, first, I need to write the status of things somewhere,  
it's easy to just have a writeln in a console application, but in a windows 
application, I have no idea how I would make some kind of text box to display 
this information.   Also, I want this program to start executing immediately, 
and if no user intervention is needed, I want it to launch, perform all tasks, 
and exit.  I just don't have anything to put on a form because the intent is 
that the user would only interact with this program if it encountered an error, 
or if the user needed to specify the output file name.

 

So my question is, how can I use Ifilesavedialog with just FreePascal in a 
console application?  I tried just accessing it the same as I did messagebox, 
but I just get an error stating the function is not found.   It seems like I 
ran across this before, I wanted to use a Windows API function that was not 
included in the windows unit and I was somehow able to add access to it on my 
own,  but I just can't recall now what function that was, or what program I was 
working on that needed it, or how it was accomplished.   Perhaps it is in the 
windows unit, or another unit, but I'm just not calling it correctly.   Current 
version of my program that uses message boxes for errors is below.

 

James

 

Program JobsList;

Uses CRT,Classes,Sysutils,windows;

Var

   TapFileRemainder,TapFileHeader,TapFileJobsList : tstrings;

   TapFileName,TapFileData,OutputTapFileName  : AnsiString;

   TapFile: Text;

   TapFileHeaderActive: Boolean;

   StringCount: LongInt;

Begin

   If ParamStr(1)<>'' Then

  Begin

 TapFileName:=ParamStr(1);

 If FileExists(TapFileName) Then

Begin

   TapFileHeaderActive:=True;

   Assign(TapFile,TapFileName);

   Reset(TapFile);

   TapfileHeader:=TStringlist.Create;

   TapfileJobsList:=TStringlist.Create;

   TapfileRemainder:=TStringlist.Create;

   While not(EOF(TapFile)) do

  Begin

 Readln(Tapfile,TapFileData);

 If TapfileHeaderActive then

Begin

   If TapFileData='Call [Subroutines]' Then

  Begin

 Writeln('Subroutine Section Found');

 TapFileHeaderActive:=False

  End

   Else

   If Copy(TapFileData,1,15)='Tap File Name =' Then

  Begin

 
OutputTapFileName:=Copy(TapFileData,16,Length(TapFileData)-15);

 Writeln('Saving to: '+OutputTapFileName);

  End

   Else

  TapfileHeader.Add(TapFileData)

End

 Else

Begin

   If Copy(TapFileData,1,6)='[Job #' Then

  Begin

 Writeln(TapFileData);

 TapFileJobsList.Add('Call '+TapFileData);

  End;

   TapfileRemainder.Add(TapFileData)

End;

  End;

   Close(TapFile);

   If OutputTapFileName='' Then

  Begin

 {Do something to get filename from windows Save-As dialog}

 {OutputTapFileName:= 
Whatever-was-received-by-Windows-Save-As-dialog;}

  End;

   If OutputTapFileName<>'' Then

  Begin

 Writeln('Writing 
',TapFileHeader.count+TapFileJobsList.count+TapFileRemainder.count,' Lines to: 
'+OutputTapFileName);

 Assign(TapFile,OutputTapFileName);

 ReWrite(TapFile);

 If TapFileHeader.count > 1 then

 For StringCount:=0 to 

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread Ralf Quint

On 11/3/2018 7:00 AM, James wrote:


That is correct, I have only ever done console programming, but now I 
find I'm lost trying to do any kind of GUI programming.    I have a 
very simple program that works as a console application, but what I 
would like to do is have it use the Windows "Save AS' Dialog to allow 
the user to save the file using the windows GUI interface, so the user 
can navigate through directory structures and save the file.


I looked at a few tutorials and see how to make a form and put some 
buttons on it, but I'm still trying to figure out how to get the 
save-as box to come up and how to then use the given file name and 
path in the program for the actual write operation..  Here’s my 
console program.. it’s pretty simple, but I really don’t know where to 
even start to convert it into a GUI program.  On line 51, if the 
output file has not been defined yet, I want to launch the save-as 
dialog, then on line 54, assign whatever save-as returns to my 
OutputFileName Variable.


The main thing to keep in mind that the main program loop in a GUI 
program is to handle all the (internal) GUI stuff, not your console 
program loop. A RAD tool like Lazarus, will conveniently handle that for 
you.


And you can't just pop up a dialog window without having a window/form 
in the first place.


In general, the logic of a GUI based program (regardless if Windows, 
macOS, Linux, etc) simply is different from a console program. Your 
console program main loop simply  pretty much just becomes a procedure 
within the GUI main loop.


Ralf



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread Ewald
On 11/03/2018 03:00 PM, James wrote:
> That is correct, I have only ever done console programming, but now I
> find I'm lost trying to do any kind of GUI programming.    I have a very
> simple program that works as a console application, but what I would
> like to do is have it use the Windows "Save AS' Dialog to allow the user
> to save the file using the windows GUI interface, so the user can
> navigate through directory structures and save the file.
> 
>  
> 
> I looked at a few tutorials and see how to make a form and put some
> buttons on it, but I'm still trying to figure out how to get the save-as
> box to come up and how to then use the given file name and path in the
> program for the actual write operation..  Here’s my console program..
> it’s pretty simple, but I really don’t know where to even start to
> convert it into a GUI program.  On line 51, if the output file has not
> been defined yet, I want to launch the save-as dialog, then on line 54,
> assign whatever save-as returns to my OutputFileName Variable. 

For the simple stuff like displaying a message box or acquiring a
filename, you could use the the common dialog boxes of windows
(comdlg32), for example:

https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/nf-commdlg-getsavefilenamea

I now see that this API has in fact been superseded by something
different, but it should give you an idea.

I do have to mention that things never stay "simple" though. Sooner
rather than later you'll find yourself in a situation where you need
more than just that basic functionality, and than you need to start
using something different altogether (unless handling the event loop
manually and fixing every last detail for every last use case of a user
out there is your thing :-) ). For that purpose I would recommend the
usage of some GUI toolkit: lazarus has been mentioned, similar things
include fpGui and MSE, others possible exist as well. If you like to
keep GUI and functionality apart from one another and have no problem
with the GUI being written for a large part in a different language,
have a look at Qt (possible with Qt4pas, if you insist on using pascal
for the GUI).

Anyway, enough on the toolkits out there, a google search will quickly
yield you a lot more than I can mention in this mail :-)

-- 
Ewald
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Listing the type (even as string) of the parameters and the return of a function

2018-11-03 Thread silvioprog
On Thu, Nov 1, 2018 at 2:11 AM silvioprog  wrote:
[...]

> I took a look at some System V ABI manuals to start a draft based on them,
> adapting the assembly to the InvokeKernelWin64() signature idea. The
> draft works fine for six or more arguments and returns the function value
> too, but I need to check (probably next weekend) how to pass floating-point
> values to the XMM registers (I'm looking for references/manuals about).
>

Finally, I found a awesome material to study: the GCC's X86-64 assembly for
compiler writers. And after some successful tests, I concluded that:

- floating-point types with size 8 or less (double, single etc.) must be
set in XMM registers aligned in 8;
- floating-point types larger than 8 (extended) must be pushed to the stack
aligned in 10.

This is a small example to check it (environment used in the tests: Lazarus
2.1.0 r59363 FPC 3.1.1 x86_64-linux-gtk2):

===
program project1;

{$MODE DELPHI}
{$MACRO ON}
//{$DEFINE USE_EXTENDED}
{$IFDEF USE_EXTENDED}
 {$DEFINE FLOAT_TYPE := extended} // size 10
{$ELSE}
 {$DEFINE FLOAT_TYPE := double} // size 8
{$ENDIF}

uses sysutils;

procedure test(const a, b: FLOAT_TYPE);
begin
  writeln(a:0:2, ' - ', b:0:2);
end;

procedure call_test(arr: pointer; f: codepointer); assembler; nostackframe;
asm
  { save the base pointer }
  pushq %rbp
  { set new base pointer }
  movq  %rsp, %rbp

  { save callee-saved registers }
  pushq %rbx
  pushq %r12
  pushq %r13
  pushq %r14
  pushq %r15

{$IFDEF USE_EXTENDED}
  leaq 0(%rdi), %rdx
  movq (%rdx), %rax
  movq %rax, (%rsp)
  movq 0x8(%rdx), %ax
  movq %ax, 0x8(%rsp)

  leaq 10(%rdi), %rax
  movq (%rax), %rdx
  movq %rdx, 0x10(%rsp)
  movq 0x8(%rax), %ax
  movq %ax, 0x18(%rsp)
{$ELSE}
  movq 0(%rdi), %xmm0
  movq 8(%rdi), %xmm1
{$ENDIF}

  { call the function }
  callq *%rsi

  { restore callee-saved registers }
  popq %r15
  popq %r14
  popq %r13
  popq %r12
  popq %rbx

  { reset stack to base pointer }
  movq %rbp, %rsp
  { restore the old base pointer }
  popq %rbp
  { return to caller }
  retq
end;

var
  arr: array of FLOAT_TYPE;
begin
  Writeln(IntToStr(SizeOf(FLOAT_TYPE)));
{$PUSH}{$WARN 5090 OFF}
  setlength(arr, 2);
{$POP}
  arr[0] := 12.34;
  arr[1] := 45.67;
  call_test(@arr[0], @test);
end.
===

and the results was:

//{$DEFINE USE_EXTENDED}:

===
...
8
12.34 - 45.67
===

{$DEFINE USE_EXTENDED}:

===
...
10
12.34 - 45.67
===

I'm going to clone the Free Pascal repository from Github to work on this
feature (sysv ABI for Linux 64 for now). After some functional code I'll
send it as patch to the Mantis issues. I'm very interested in rtti.invoke()
support on Linux/ARM and Win32. :-)

(P.S.: Could you check the issue #34496? I'm not sure if saving the base
pointer is best way to solve the problem, but at least fixed the AV for
extended types)

--
Silvio Clécio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-03 Thread James
That is correct, I have only ever done console programming, but now I find I'm 
lost trying to do any kind of GUI programming.I have a very simple program 
that works as a console application, but what I would like to do is have it use 
the Windows "Save AS' Dialog to allow the user to save the file using the 
windows GUI interface, so the user can navigate through directory structures 
and save the file.

 

I looked at a few tutorials and see how to make a form and put some buttons on 
it, but I'm still trying to figure out how to get the save-as box to come up 
and how to then use the given file name and path in the program for the actual 
write operation..  Here’s my console program.. it’s pretty simple, but I really 
don’t know where to even start to convert it into a GUI program.  On line 51, 
if the output file has not been defined yet, I want to launch the save-as 
dialog, then on line 54, assign whatever save-as returns to my OutputFileName 
Variable.  

 

 

Program JobsList;

Uses CRT,Classes,Sysutils;

Var

   TapFileRemainder,TapFileHeader,TapFileJobsList : tstrings;

   TapFileName,TapFileData,OutputTapFileName  : String;

   TapFile: Text;

   TapFileHeaderActive: Boolean;

   StringCount: LongInt;

Begin

   If ParamStr(1)<>'' Then

  Begin

 TapFileName:=ParamStr(1);

 If FileExists(TapFileName) Then

Begin

   TapFileHeaderActive:=True;

   Assign(TapFile,TapFileName);

   Reset(TapFile);

   TapfileHeader:=TStringlist.Create;

   TapfileJobsList:=TStringlist.Create;

   TapfileRemainder:=TStringlist.Create;

   While not(EOF(TapFile)) do

  Begin

 Readln(Tapfile,TapFileData);

 If TapfileHeaderActive then

Begin

   If TapFileData='Call [Subroutines]' Then

  Begin

 Writeln('Subroutine Section Found');

 TapFileHeaderActive:=False

  End

   Else

  If Copy(TapFileData,1,15)='Tap File Name =' Then

  Begin

 
OutputTapFileName:=Copy(TapFileData,16,Length(TapFileData)-15);

 Writeln('Saving to: '+OutputTapFileName);

  End

   Else

  TapfileHeader.Add(TapFileData)

End

 Else

Begin

   If Copy(TapFileData,1,6)='[Job #' Then

  Begin

 Writeln(TapFileData);

 TapFileJobsList.Add('Call '+TapFileData);

  End;

   TapfileRemainder.Add(TapFileData)

End;

  End;

   Close(TapFile);

   If OutputTapFileName='' Then

  Begin

 {Do something to get filename from windows Save-As dialog}

 OutputTapFileName:= 
Whatever-was-received-by-Windows-Save-As-dialog;

  End;

   If OutputTapFileName<>'' Then

  Begin

 Writeln('Writing 
',TapFileHeader.count+TapFileJobsList.count+TapFileRemainder.count,' Lines to: 
'+OutputTapFileName);

 Assign(TapFile,OutputTapFileName);

 ReWrite(TapFile);

 If TapFileHeader.count > 1 then

 For StringCount:=0 to TapFileHeader.count-1 do

Writeln(TapFile,TapFileHeader[StringCount]);

 If TapFileJobsList.count > 1 then

 For StringCount:=0 to TapFileJobsList.count-1 do

Writeln(TapFile,TapFileJobsList[StringCount]);

 If TapFileRemainder.count > 1 then

 For StringCount:=0 to TapFileRemainder.count-1 do

Writeln(TapFile,TapFileRemainder[StringCount]);

 Close(TapFile);

  End

   Else

  Begin

 Writeln ('No Output Tap File Specified in Program');

 Readln;

  End;

   TapFileHeader.Free;

   TapFileJobsList.Free;

   TapFileRemainder.Free;

End

 Else

Begin

   Writeln (TapFileName,' Not Found');

   Readln;

End;

  End

   Else

  Begin

 Writeln ('No File Name Specified');

 Readln;

  End;

End.

 

James


[fpc-pascal] MSEide+MSEgui 4.6.2

2018-11-03 Thread Martin Schreiber
Hi,

MSEide+MSEgui version 4.6.2 has been released:
https://sourceforge.net/projects/mseide-msegui/files/mseide-msegui/4.6.2/
Have a lot of fun!

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2jni issues

2018-11-03 Thread Yuriy Sydorov

On 10/31/2018 3:23 PM, kst...@gmail.com wrote:

I would like to make a suggestion regarding the generated code of the
pas2jni utility, and report an issue.

This utility generates a java file called system.java. First thing is that
there is a reference to TClass which is a non-existent Java class:
   static TClass GetTClass(int index) { TClass c = new TClass(null);
c._pasobj=GetClassRef(index); return c; }

In order to compile the generated system.java I had to comment out this
line. I didn't look too deep to see how/where it is used, yet for my needs
this did the work. I assume something simple is missing there.


This issue happens when no classes are used in your code. If you add usage of 
TObject, the Java code will work.
I've fixed this in trunk in r40179.


Second thing is the way this file has hard-coded the loading of the .dll
file: There is a static IniJni() method that is called with a static class
initializer:
   static { com.imagetrust.launch.winutils.system.InitJni(); }
This is a technique that excludes any other way of dynamically loading the
.dll file. This is a show-stopper for cases where dll files are packaged in
a jar file and are loaded dynamically with System.load. As the code is
written, the assumption is that the jni dll file always exists in
java.library.path.


In r40179 I've added the "-N" switch to pas2jni which prevents auto-loading of 
the shared library.

Just get the latest trunk sources of pas2jni and compile it to get the fixed 
version.

Yuriy.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal