Trying to understand RB string functions

Discussion forum about all things Report Builder (all versions).
rogeryeoh

Trying to understand RB string functions

Post by rogeryeoh » 03 Jun 2009, 01:06

System : Vista, TD 4.2, RB 4.2, SQLBase 9.01

I finally have a real requirement to use the conditional display feature of RB for the 1st time. It goes like this :

1 Industry ('OP' or anything else) as a parent to many industry types ('FD', 'PLT', 'OLF' for 'OP' industry or anything else for the others)

1) When it's not an 'OP' industry, I print standard fields and columns.
2) When I get an 'OP' industry code coming in, I need to print an extra 2 fields, regardless of industry type
3) When industry type under 'OP' is 'FD', I need to print another 8 headings and 16 data fields

With input items defined for industry and industry type, I tried to define the 2 simple conditions as formulae to be :
Industry = 'OP'
and
IndustryType = 'FD'
expecting to get a 0 or 1 (non-zero which would fulfil the conditional display)

Both failed with ERR_SYNTAX: Incorrect or invalid formula

I then used
StrCompare( Industry , 'OP' )
and
StrCompare( IndustryType, 'FD' )
but when the conditions were fulfilled, the formulae returned a 0. And when they weren't fulfilled, they returned a 1. Isn't this kind of reversed from what we'd expect from a comparison function? I then had to add a -1 to each formula to make the 1 a zero and the zero a -1 in order to get the conditional display to work. Part of the problem here is that I couldnt find any documentation on the StrCompare or StrIff or ANY of the RB functions, other than a descriptive summary of what they do. Nothing on parameters at all, so I'm just guessing what to use here.

Any help please?

Ren

Re: Trying to understand RB string functions

Post by Ren » 03 Jun 2009, 02:27

IF:

string1 < string2 returns a value less than zero (<0 )
string1 = string2 returns a zero (0 )
string1 > string2 returns a value greater than zero (>0 )
StrCompare uses ascii sort. as you can see in the help file ;) Since it can be used as a sort function, the returned value is absolutely correct.

User avatar
Charlie
Canada
Posts: 649
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: Trying to understand RB string functions

Post by Charlie » 04 Jun 2009, 07:37

Hello,

NumberIff( StrCompare(Industry, 'OP'), 0, 1, 0)

NumberIff( StrCompare(IndustryType, 'FD'), 0, 1, 0)

Cheers and best regards.

User avatar
Charlie
Canada
Posts: 649
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: Trying to understand RB string functions

Post by Charlie » 04 Jun 2009, 07:49

From the Team Developer Help file:

NumberIFF(nInput,number1,number2,number3)
Returns one of number1, number2, or number3, depending on the value returned by the nInput parameter.

Parameters
nInput
number1
number2
number3

If:
nInput < 0 number1 is returned
nInput = 0 number2 is returned
nInput > 0 number3 is returned

Example:
NumberIFF(2,22,55,77)
In this example, the NumberIFF function returns the value 77.

rogeryeoh

Re: Trying to understand RB string functions

Post by rogeryeoh » 04 Jun 2009, 09:18

Charlie,

Thanks so much, that's precisely what I needed to know about the parameters. Using Vista is such a pain. I downloaded Microsoft's win32hlp file but somehow in RB when I do an F1 on a function like StrCompare, it tells me something is missing.. So where did you get your documentation from?

Cheers

roger

FRBhote
India
Posts: 2212
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Re: Trying to understand RB string functions

Post by FRBhote » 05 Jun 2009, 00:28


User avatar
Charlie
Canada
Posts: 649
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: Trying to understand RB string functions

Post by Charlie » 05 Jun 2009, 10:48

Hi,

I was first going to send the same link as FR has done, then realized digging that the on-line docs do not have complete descriptions of Report Windows functions.

I'm working with TD2.1 on Vista, so I found it a real pain that I couldn't open up the help files that come with TD2.1

Instead of downloading WinHlp32.exe from MS (http://support.microsoft.com/kb/917607), I:
  • grabbed winhlp32.exe off a Windows XP machine
  • copied that file onto my Vista machine
  • right-clicked on the Centura.hlp file, chose "open with" and associated the hlp file with that exe I copied
Not pretty, who knows what problems I may run into later, but it works well enough for now.

Cheers.

rogeryeoh

Re: Trying to understand RB string functions

Post by rogeryeoh » 05 Jun 2009, 17:31

I have this link, but it still does not detail the parameters for each function. Apparently pressing <F1> on a function would show the detailed info, but because I'm using Vista, it does not work. And even after I've downloaded Microsoft's winhelp32 program, there's still no content.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests