Recent

Author Topic: Scripts  (Read 22165 times)

tshumak

  • New Member
  • *
  • Posts: 36
Scripts
« on: December 10, 2013, 09:42:47 am »
I'm trying to get this script to run, but LazReport is not creating the variables.  I saw in a prior post that running a script in a masterdata band will create variables however only the first variable is created. I tried shifting the statements around, but again only the first is created.

Am I missing something. not doing something right?  What is the correct way I can make this script create all the variables?

Code: [Select]
BMONTH:=MONTHOF([SysParm."UPDATE_DATE"]);
BILLYEAR:=STR(YEAROF([SysParm."UPDATE_DATE"]))+'-'+STR(BMONTH);

DLQ :=0.0;
CDUE:=0.0;
PMT:=0.0;

LATE_FEE:=0;

NONMEMBER:=Pos('N',[Lot_ID."Flags"]);
GOLDEN:=Pos('G',[Lot_ID."Flags"]);
LIENED:=Pos('L',[Lot_ID."Flags"]);

AD1:=[Names."LNAME_CO"]+', '+[Names."FNAME"];
if [LENGTH([Names."CARE_OF"])]>0 then
Begin
  AD2:=[Names."CARE_OF"]
  AD3:=[Addr."ADDRESS"];
  AD4:=[Addr."CITY"]+', '+ [Addr."STATE"]+' '+ [Addr."ZIP"]];
  if not  [COMPARESTR([Addr."COUNTRY"], ['USA'])=0] then
  begin
    AD5:=[Addr."COUNTRY"]
  end
  else
  begin
    AD5:='';
  end;
end else begin
  AD2:=[Addr."ADDRESS"];
  AD3:=[Addr."CITY"]+', '+ [Addr."STATE"]+' '+ [Addr."ZIP"]];
  if not  [COMPARESTR([Addr."COUNTRY"], ['USA'])=0] then
  begin
    AD4:=[Addr."COUNTRY"]
  end
  else
  begin
    AD4:='';
  end;
  AD5:='';
end;


MSG1:='.                              Highway Lot - NO PAYMENT REQUIRED';
MSG2:='Your Property has been Liened because of non-payment of Fees';
MSG3:='.           Fee Required to File the Lien Release - $'+FORMATFLOAT([#0.00], [SysParam."Lien_R_Fee"]);
MSG4:='.                Your Balance is Zero - NO PAYMENT RTEQUIRED';
MSG5:='.                         ***  Your Account is Past Due  ***';

MSGL1:='***  A 12% Late Fee will be charged if not paid by the due date  ***';
MSGL2:='***  A 12% Late Fee has been added to the DUE amount above  ***';

Thanks.

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #1 on: December 11, 2013, 08:30:32 am »
60 views and no reply's yet? 

Maybe they don't understand my post.  What I would like to do is to create variables inside of Lazreport like this thread suggests. http://forum.lazarus.freepascal.org/index.php/topic,17190.msg94901.html#msg94901  Here it runs a small script inside the MasterData band.  Click Preview.  then check the variables list and there supposed to be created.  With my script, only the first variable is created.  when I shuffle the statements around, still only the first statement that assigns a value to a variable, only that variable is created.  No other variables are created. 

I would like to have the script create all the variables.  Is this a limitation to LazReport?  Does it only create one variable per script? Or am I doing something wrong?

Thanks for the views and reply's.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Scripts
« Reply #2 on: December 11, 2013, 09:22:21 am »
Maybe you didn't give enough information to let people help you easily. Laz version, FPC version, operating system, compilable sample project...

See first link in my signature...

I'm not a Lazreport user, but your problem description was very clear to me though ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #3 on: December 11, 2013, 09:36:13 am »
Sorry, I dont mean to be sarcastic here, I was just commenting on the number of views and no posts.  Perhaps they dont know which is why their here looking for answers themselves such as I.

 Anyway, I tried to clarify things with my second post.  Sample code in in my first.  Lazarus version 1.1, FPC 2.7.1, Win7-64.  Big Chimp, This is the version you suggested to me in another post.  If this is not current, I could update.  Any way do you have any suggestions for my coding?

Thanks again.
« Last Edit: December 11, 2013, 09:45:34 am by tshumak »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Scripts
« Reply #4 on: December 11, 2013, 12:28:46 pm »
No problem with any sarcasm - you did explain your problems quite well and that's the main thing ;)

Sample code in in my first. 
Sorry to be pedantic: yes there is sample code in the first post. No, there is no project you can run that includes sample data, report definition etc. However, it's of course your choice how much effort you want to invest into posting questions. I myself tend to favour ready made example projects in order to exclude as much uncertainty as possible (and if needed, serve as possible bug report test cases) but a lot of questions have less and do get answered.

Lazarus version 1.1, FPC 2.7.1, Win7-64.  Big Chimp, This is the version you suggested to me in another post. 
If this is not current, I could update. 
Could be depending on what you wrote in that other post. Normally I'd probably recommend using stable FPC with either latest SVN/dev Lazarus or latest stable Lazarus.
IIRC, 1.1 is an SVN version, right? Meanwhile Laz svn is at 1.3; you could try updating your Laz version..

Any way do you have any suggestions for my coding?
No, sorry, haven't used Lazreport in anger, really. I'd make sure you have the latest Laz+Lazreport as Lazreport does get quite some fixes.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

ttomas

  • Full Member
  • ***
  • Posts: 245
Re: Scripts
« Reply #5 on: December 11, 2013, 03:28:26 pm »
Put your script in begin end; block

Code: [Select]
begin
  // Your script code here
end;

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #6 on: December 12, 2013, 08:18:28 am »
I dont remember the thead as to why i went with The svn.  I think it might have been something about installing.  You know your probably right.  In my line of work, I'm always one to push for updates,  update windows, office, java, flash, etc. I don't think it will help but that svn had a lot of new cool stuff.  I'll try the latest svn and see what happens.

Ttomas-  I'll try the begin - end statements and write back.  Thanks.

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #7 on: December 12, 2013, 08:55:33 am »
Hey TTomas -

You the one!  That seems to have worked.  Thanks again.

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #8 on: December 13, 2013, 07:38:57 am »
Well for the most part it worked.  Up until the if block.  Too bad there's no way to step through the code.

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #9 on: December 29, 2013, 09:23:32 pm »
I've worked with this for a while now and I'm finding that the interpreter seems to want semi-colons after 'each' line and does not like nested IF statements.

For example:
Code: [Select]
if [[PAY]>0] then begin
if[[LATE_FEE]=1] then Text:=[MSGL2];
else Text:= [MSGL1];
end;

Does not compile.  However if I remove the outer if statement:

Code: [Select]
if[[LATE_FEE]=1] then Text:=[MSGL2];
else Text:= [MSGL1];

Does run.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Scripts
« Reply #10 on: December 30, 2013, 11:24:29 am »
@tshumak: thanks a lot for your digging. Would you mind checking my takeway from this post
http://wiki.lazarus.freepascal.org/LazReport_Documentation#Script

Of course, additions and corrections in other parts welcome, too ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tshumak

  • New Member
  • *
  • Posts: 36
Re: Scripts
« Reply #11 on: December 31, 2013, 09:05:32 am »
Thanks for the reply.  tried the link but it does not open.  Were having some heavy rain and lightning storms over here, might be related.  I'll try checking again later.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Scripts
« Reply #12 on: December 31, 2013, 09:49:03 am »
Don't think the problem is at your end, I have the same... and:
http://www.downforeveryoneorjustme.com/www.http://wiki.lazarus.freepascal.org/
shows it's down
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

adilsonpazzini

  • New Member
  • *
  • Posts: 29
Re: Scripts
« Reply #13 on: July 26, 2018, 10:58:45 pm »
LazReport Script...

Is it possible to concatenate the result of the Text property?


IF [VEIM11NEF.QRel."VR_AVISTA"]>0 THEN
 TEXT:= ' V_V';

IF [VEIM11NEF.QRel."VR_USADO"] = 0 THEN
 TEXT := TEXT + ' S_U'
ELSE
 TEXT := TEXT + ' C_U';

adilsonpazzini

  • New Member
  • *
  • Posts: 29
Re: Scripts
« Reply #14 on: July 26, 2018, 11:08:15 pm »
BEGIN
X:='';
IF [VEIM11NEF.QRel."VR_AVISTA"]>0 THEN
I managed using Variavel.

thank

 X:= ' V_V';

IF [VEIM11NEF.QRel."VR_USADO"] = 0 THEN
 X := X + ' S_U'+ [VEIM11NEF.QRel."VR_USADO"]
ELSE
 X := X + ' C_U'+ [VEIM11NEF.QRel."VR_USADO"];

TEXT := X;

END;
                                                 

 

TinyPortal © 2005-2018