String in parentheses - crystal-reports

I recently have seen an expression in Crystal. It's a formula, when I edit it, its content is something like this:
("sNumber") + ":"
However, when I print this report, the code above will become: Number:
I think ("sNumber") is something like a variable. But I cannot find where it is be declared. I searched a lot on web but I find nothing.
So my question is:
Where can I find it?
How can I edit its value?
Any help would be welcome!
UPDATE:
I tried some expression, and find out all string after "s" will be displayed on the report, and those before "s" will be removed.
Maybe it's just some string expression not in document. If someone knows the specification, please add below.

After some further test, I have to say it is not a variable. It's just that everything after the letter "s" will be printed.
But I can see the whole string "sNumber" in the preview view.
My conclusion is if I want to change it, just modify the string after "s".

try this in your Formula "(""sNumber"") :" if you just need to create it as string

Related

String or string literal fails

I am trying something simple to follow exercises in a book. For example, typing “hello” at the prompt in the interactions window.
I get the the following error:
“a”: unbound identifier in module in: “a”
I believe simple things like this worked before, so I want to know what to check to resolve this problem.
Your problem are the quotation marks, a very common problem. Look:
“a”
The quotation marks look italic.
They should be like this: "a".
Copy paste this into your REPL and print return (this time it will work!):
"hello"
This is written with the right quoation marks "" and not “” .
If you copy paste from pdf books somteims this wrong quotation marks appear as a result (like Realm of Racket - because recently I had that problem when copy pasting from it). (Quotation marks from MS Word when using Times Romans fonts are also from this strange type, and in some programming blogs, too, the quotation marks are spoiled when copy pasting out of them).
How to avoid it?: Type the examples manually into the DrRacket editor. - problem solved! Plus you learn the things anyway much better if you type them yourself - ("the hard way" approach ;) ).
And you learn, that even copy pasting is a skill which one sometimes has to learn anew - welcome to programming (the long road of learning) :D .
Remember to enter the quotes " around the hello too.
"hello" is a string which contains the text hello
hello is a name of an variable (an identifier),
so if you haven't defined the name hello you get an
error saying that the identifier is undefined

Strip excess padding from a string

I asked a question earlier today and got a really quick answer from llbrink. I really should have asked that question before I spent several hours trying to find an answer.
So - here's another question that I have never found an answer for (although I have created a work-around which seems very cludgy).
My AHK program asks the user for a login name. The program then compares the login name with an existing list of names in a file.
The login name in the file may contain spaces, but there are never spaces at the beginning of the name. When the user enters the name, he may include spaces at the beginning. This means that when my program compares the name with those in the file, it can not find a match (because of the extra spaces).
I want to find a way of stripping the spaces from the beginning of the input.
My work-round has been to split the input string into an array (which does ignore leading spaces) and then use the first element of the array. This is my code :
name := DoStrip(name)
DoStrip(xyz) ; strip leading and trailing spaces from string
{
StringSplit, out, xyz, `,, %A_Space%
Return out1
}
This seems to be a very laboured way to do it - is there a better way ?
I don't see a problem with your example if it works on all cases.
There is a much simpler way; just use Autotrim which works like this.
AutoTrim, On ; not required it is on by default
my_variable = %my_variable%
There are also many other different ways to trim string in autohotkey,
which you can combine into something useful.
You can also use #LTrim and #RTrim to remove white spaces at the beginning and at the end of the string.

Dollar sign in text when passing variable

I got stricky/old php code, I just try to clean it , fix some bugs, and so on. Also the server uses php 4 too.
The problem is the following:
I get some data back from the database, I work with those data and show them. If the result contains a dollar sign, the PHP try to handle it as a variable.
For example :
$result = $this->sqlresult('SELECT * From Tablename where id=15');
$details = $result['description'];
echo $details;
Let me show an example what's happening , when the $result['description'] contains any wrong text, like 'This book is available for $148':
It usually doesn't show anything or show a wrong text , like This book is available for 48.
I have tried a preg replace functions on the details, I was looking for char changes , or html_special_chars , and tried those too, but nothing happened or not the original text came up.
preg_replace('/\$ /','/&#36/;' $details);
I know , that the double quotes on passing variables causes a similar error. I checked this topic too, but it wasn't a solution for me.
Current solution is just adding an extra space between the price amount the $ sign, but I am looking for a better one.
preg_replace('/\$/','/\$ /' $details);
Have you tried to use escape characters? This book is \$148.

JasperReports Text Field Expression doesn't really let me put in anything except a variable or field reference

Referencing the page number variable in JasperReport as $V{PAGE_NUMBER}. Of course that works fine. However, I would like this report to have a page number preceded by a letter, as in:
A-1
A-2
...
A-N
Unfortunately, this does not appear to be permitted. Even when I get the expression editor to accept an expression, it still fails to compile. Always with "cannot cast from String to Integer", or "cannot cast from Integer to String" errors, or sometimes both.
"A-".concat($V{PAGE_NUMBER}.toString()) does not work. No possible variation works, mystifyingly.
Just a note, you can write it as "A-" + $V{PAGE_NUMBER}
Yeah, you can't teach smart. I neglected to change the field type from Integer to String. And I was about to disparage an awesome free product. D'Oh.

crystal reports : substring error

I've developed a workaround since crystal reports doesn't seem to have a substring function with the following formula:
right({_v_hardware.groupname},
truncate(instr(replace({_v_hardware.groupname},".",
","), ","))
What I'm trying to do is search for the period (".") in a string and replace it with a comma. Then find the comma position in the string and print all characters following after the comma. This is assuming the string will only have 1 period in the entire string.
Now when I attempt to do this, I get some weird characters which look like wingdings. Any ideas?
thanks in advance.
I don't know the entire issue that you are attempting to accomplish, but for this question alone, the step of replacing the period with a comma seems to be unnecessary. If you know that there is only one period in the string and you only want the characters right of the period then you should be able to do something like the following (this is #first_formula):
right({_v_hardware.groupname}, len({_v_hardware.groupname}) - instr({_v_hardware.groupname},"."))
If for some reason you want to show the comma then I'd do that in a separate formula. If you need the entire screen with the comma replaced then just do:
replace({_v_hardware.groupname},".",",")
And if you need the comma plus included in the string then it might just be easier to do something like:
"," + {#first_formula}
Hope this helps.