Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Syntax advice please! Post Reply Post New Topic
Author Message
BarMan
Newbie
Newbie


Joined: 14 Nov 2010
Online Status: Offline
Posts: 5
Quote BarMan Replybullet Topic: Syntax advice please!
     Posted: 17 Nov 2010 at 11:59pm
We have a report created in Crystal V10, which calls a subroutine to create an address string. The string is only created when there is an entry in the first field (ADDR1), but is blank if the address fields are only partially filled. (for example, if we only know the town, and the only field with data is ACCOUNT.TOWN).
The string creation routine looks like this:
 

local stringvar address;

address:="";

 

address:=

if ( not isnull({ACCOUNT.ADDR1})) or ( {ACCOUNT.ADDR1}<>"" ) then address:=address+{ACCOUNT.ADDR1};

if ( not isnull({ACCOUNT.ADDR2})) or ( {ACCOUNT.ADDR2}<>"" ) then address:=address+", "+{ACCOUNT.ADDR2};

if ( not isnull({ACCOUNT.ADDR3})) or ( {ACCOUNT.ADDR3}<>"" )then address:=address+", "+{ACCOUNT.ADDR3};

if ( not isnull({ACCOUNT.TOWN})) or ( {ACCOUNT.TOWN}<>"" ) then address:=address+", "+{ACCOUNT.TOWN};

if ( not isnull({ACCOUNT.COUNTY})) or ( {ACCOUNT.COUNTY}<>"" ) then address:=address+", "+{ACCOUNT.COUNTY};

if ( not isnull({ACCOUNT.POSTCODE})) or ( {ACCOUNT.POSTCODE}<>"" ) then address:=address+", "+{ACCOUNT.POSTCODE};

if ( not isnull({COUNTRY.DESCRIPTION})) or ( {COUNTRY.DESCRIPTION}<>"" ) then address:=address+", "+{COUNTRY.DESCRIPTION};

address;

If you could please let me know where the syntax is incorrect, I'd be very grateful! 

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Nov 2010 at 3:29am

address:=

if ( not isnull({ACCOUNT.ADDR1})) or ( {ACCOUNT.ADDR1}<>"" ) then address:=address+{ACCOUNT.ADDR1};

the very first line makes no sense. (address :=).  You are doing the assignment in the if statement. 

 I would try removing it and see how things go.
 
HTH


Edited by lockwelle - 18 Nov 2010 at 3:30am
IP IP Logged
BarMan
Newbie
Newbie


Joined: 14 Nov 2010
Online Status: Offline
Posts: 5
Quote BarMan Replybullet Posted: 18 Nov 2010 at 4:06am
Thank you for this! I tried your suggestion, but it does the same thing. I'll try again in the morning after our server reboots - something might be sat in cache somwhere.
IP IP Logged
JohnT
Groupie
Groupie
Avatar

Joined: 20 Jan 2008
Online Status: Offline
Posts: 92
Quote JohnT Replybullet Posted: 19 Nov 2010 at 4:11am
I agree with Lockwelle.  The 3rd line "Address:=" should be removed.  If you are still getting the syntax error, I would comment all the If lines except one and try to fix that line.  When you get that one line right, remove the next comment and see if the syntax is correct.  If not, fix that line and remove the next comment.    Keep going until you remove all the comments and all the syntax is correct.
IP IP Logged
BarMan
Newbie
Newbie


Joined: 14 Nov 2010
Online Status: Offline
Posts: 5
Quote BarMan Replybullet Posted: 19 Nov 2010 at 5:53am
I think the main issue is with how Crystal handles null values. There is a setting which tells Crystal to set null results to the default value (e.g. null number values to 0). I'll try this setting and let you know if it works. Thank you for your help so far!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Nov 2010 at 6:02am
try changing your parenthesis... 

if not (isnull({ACCOUNT.ADDR1}) or {ACCOUNT.ADDR1}<>"" ) then....



Edited by DBlank - 19 Nov 2010 at 6:03am
IP IP Logged
BarMan
Newbie
Newbie


Joined: 14 Nov 2010
Online Status: Offline
Posts: 5
Quote BarMan Replybullet Posted: 22 Nov 2010 at 5:33am
Damn and blast! The report runs through a Crystal report viewer over our company intranet. I copied the modified report to the location where the intranet calls the report from, and I received an error message "unable to load report". So I edited the original in it's original location, and tried to run it, which comes up with a different error message of "incorrect report version". The original problem is fixed though, when I run it locally. Now, all I have to do is get my head around the intranet!!! Cheers for you help though!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum