when parameter is blank show value instead crystal report xi - crystal-reports-xi

I have a report where I have an optional string parameter. This is Crystal Reports XI (11.0.0). In the report, I would like to display 'All' when the report is run with the parameter left blank. I have tried the following:
I right click on the field -> Format Field -> Common -> Display String
if {?Location} = '' then 'all'
if IsNull({?Location}) then
'All'
if Length({?Location})< 1 then
'All'
if Length(Trim({?Location}))< 1 then
'All'
There is also nothing printed when I put
ToText(Length({?Location}))
or
ToText(IsNull({?Location}))
Also related to this question is
How do I handle empty number fields/variables in Crystal Reports?
for which there was no accepted answer at the time of this submission. My googleing didn't turn up anything of worth.

Instead of using the Display String property, make a formula instead:
If IsNull({?Location}) Or Trim({?Location}) = "" Then
"All"
Else
{?Location}
Now drop your #Formula into the report.

Related

Custom wireshark disector shows value but fieldname is not visible using lua

I am testing some network packets of my Organisation's product. We already have custom plugins. I am trying to add some some more fields into those existing plugins (like conversion of 2 byte code to a string and assign it to a field)
Thankyou in advance for reading my query.
--edit
Wireshark version : 2.4.5 (organization's plugins dont work on latest wireshark application)
--edit
Problem statement:
I am able to add field and show value, but fieldname is not displayed as defined.
I cannot share the entire .lua file but i will try to explain What i did:
Below is the image where I have a field aprint.type. this is a two byte field. In .lua file, for display purpose it is appended with corresponding description using a custom function int_to_enum.
I want to add one more proto field aprint.typetext which will show the text.
What I did:
Added a protofield f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text") (Tried f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text",FT_STRING) also)
Below the code where subtree aprint.type is shown, added my required field as subtree:add(f_apr_msg_type_txt, msg_type_string) (Below is image of code extract)
I am able to see the text but field Name is shown as Wireshark Lua text (_ws.lua.text)
Normally displaying strings based on numeric values is accomplished by a value string lookup, so you'd have something like so:
local aprint_type_vals = {
[1] = "Foo",
[2] = "Bar",
[9] = "State alarm"
}
f_apr_msg_type = ProtoField.uint16("aprint.type", "Type", base.DEC, aprint_type_vals)
f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text", base.ASCII)
... then
local msg_type = tvb(offset, 2):le_uint()
subtree:add_le(f_apr_msg_type, tvb(offset, 2))
subtree:add(f_apr_msg_type_txt, tvb(offset, 2), (aprint_type_vals[msg_type] or "Unknown"))
--[[
Alternatively:
subtree:add(f_apr_msg_type_txt, tvb(offset, 2)):set_text("aprint_type_text: " .. (aprint_type_vals[msg_type] or "Unknown"))
--]]
I'm also not sure why you need the extra field with only the text when the text is already displayed with the existing field, but that's basically how you'd do it.

IsTradeAllowed not returning what I would expect

Please see the script below:
void OnStart()
{
Alert(IsTradeAllowed()); //alert 1
Alert(IsTradeAllowed(NULL, TimeGMT())); //alert 2
Alert(IsTradeAllowed(Symbol(), TimeGMT())); //alert 3
Alert(IsTradeAllowed("GBPUSD", TimeGMT())); //alert 4
}
This returns:
true //for alert 1
true //for alert 2
false //for alert 3
false //for alert 4
As alert 2 returns: true, then I would expect alert 3 and alert 4 to return true.
I have tried running the code at multiple times of the day on weekdays. The code returns the same result at weekends. I have also tried putting the code in a script and an EA. Every time I get the same result. Is there an explanation for this? I have tried what is suggested here: https://www.mql5.com/en/docs/runtime/tradepermission
Symbol() returns: "GBPUSD". Each alert should return true in my mind, however this does not appear to be the case here. Incidentally I have notices that Symbol() returns the symbol at the top of the demo account watchlist if the script is run inside MetaEditor, however it returns the symbol displayed on the chart if run inside the demo account.
The broker is Oanda.
Update 04/03/21 at 19:55
I have now discovered that if I right click on the Market Watch and select: show all, then more symbols appear. I can then see that some symbols are greyed out and some symbols are not. The symbols that are not greyed out e.g. USDGBP-g return what I would expect when running the program above i.e. alert 1-alert 4 =true. The symbols that are greyed out e.g. USDGBP returns true; true; false; false in the program above. I now have two questions:
Why does: IsTradeAllowed(NULL, TimeGMT()); //alert 2 return true for symbols that are greyed out?
What does -g mean in GBPUSD-g?
IsTradeAllowed checks if the Expert Advisor is allowed to trade and trading context is not busy.
The version of the function without any arguments will check if the EA has been applied with the correct permissions ("Allow live trading" ticked and "AutoTrading" enabled).
The second form of the function:
bool IsTradeAllowed(const string symbol, datetime tested_time);
checks if the EA would be allowed to trade according to the specifications for the chart selected (to view this, from the Market Watch window right click a symbol, from the menu that pops up select "Specification").
For example
IsTradeAllowed(Symbol(), D'2021.03.06 12:00');
would check if the current symbol can be traded this coming Saturday (which should be false).
If you are getting undesirable results you should check that your broker has set the "Specifications" correctly.
EDIT
I've tested the command in OANDA which is the broker you are using and the command functions as expected.
NULL is not valid for a Symbol and its use makes the command function in its first form (ie timedate is ignored).
I would suggest rather than use Alerts to examine output, try the following.
string cmnt;
cmnt=StringConcatenate("Alert 1: ",IsTradeAllowed());
cmnt=StringConcatenate(cmnt+"\r\n","Alert 2: ",IsTradeAllowed(NULL, TimeGMT()));
cmnt=StringConcatenate(cmnt+"\r\n","Alert 3: ",IsTradeAllowed(Symbol(), TimeGMT()));
cmnt=StringConcatenate(cmnt+"\r\n","Alert 4: ",IsTradeAllowed("GBPUSD", TimeGMT()));
Comment(cmnt);
I tried your script in my ICMarkets version of MetaTrader4. With disabled auto trading i get result:
When I set auto trading to enable using Ctrl+E shortcut, in all cases script return true.
I recommend you to try this script on another account or different broker. If this will help, you should communicate with your broker about this issue. The last option is a reinstall MetaTrader to make sure, that all config files are correct.

After converting field to tag, no query result

I am using Telegraf with Telemetry, I want to see traffic level on interface based on their description, "/interfaces/interface/subinterfaces/subinterface/state/description". Unfortunately the interface description was as field key, which I converted using the processors.converter. Since I needed to rewrite the data after this, I just dropped the whole measurement so the new tag can take place.
I do see the descriptions as tag fields and I do see the interface description as a tag key.
Unfortunately I am still getting blank results on any query when I try with querying by interface description.
### Relevant telegraf.conf:
# Convert values to another metric value type
[[processors.converter]]
# Fields to convert
[processors.converter.fields]
tag = ["/interfaces/interface/subinterfaces/subinterface/state/description"]
System info:
Telegraf 1.14.5
Debian
Steps to reproduce:
> select "/interfaces/interface/subinterfaces/subinterface/state/description" from "/interfaces/"
(empty result) this is expected since now its a tag
> show tag keys
name: /interfaces/
tagKey
------
/interfaces/interface/subinterfaces/subinterface/state/description
we can see here that now it's as a tag key
> show tag values with key = "/interfaces/interface/subinterfaces/subinterface/state/description"
(gives all descriptions)
> SELECT "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts" from /interfaces/ where "/interfaces/interface/subinterfaces/subinterface/state/description" = 'some_description'
(empty result) Where I would like to have some result based on the interface description
Expected behavior:
SELECT "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts" from /interfaces/ where "/interfaces/interface/subinterfaces/subinterface/state/description" = 'some_description'
to give some a result for the interface with that description
Actual behavior:
SELECT "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts" from /interfaces/ where "/interfaces/interface/subinterfaces/subinterface/state/description" = 'some_description'
(is not returning any result)
Additional information
I am also using Chronograph which gives no results too.
You cannot just select just a tag from a measurement. For influx to return results it needs atleast one field in the select clause.

How to get printer where report was printed

If PROMPT calsue is used in report
REPORT FORM xxx to PRINT PROMPT
User can select printer where report is printed.
How to get this printer name for logging?
https://support.microsoft.com/en-us/help/162798/how-to-use-the-set-printer-to-name-command-to-print-to-a-specified-printer-in-visual-foxpro
Show hot to use GetPrinter() for this. This requires removing PROMPT clause from REPORT
How to get printer where report was printed using PROMPT clause:
REPORT FORM xxx TO PRINT PROMPT
If this possbible, maybe thereis some sys() function or somethis other or is it possible to get printer name during report print ?
Or should this command re-factored not to use PROMPT clause like:
cPrinter = getprinter()
set printer to name (cPrinter)
REPORT FORM xxx TO PRINT
insert into logfile (PrinterUsedForPrinting) values (cPrinter)
I would suggest using your solution of calling GETPRINTER prior to running the report (without the PROMPT clause). In my long experience using FoxPro/VFP I don't think I've come across a way to determine the printer via REPORT FORM...PROMPT.
Here's an example wrapper function that you may find useful. I typically call "PickPrinter" prior to running a report. If PickPrinter returns an empty string, I abort the report run.
FUNCTION PickPrinter
IF APRINTERS(a_printers) < 1
MESSAGEBOX("No printers defined.")
RETURN ""
ELSE
lcPrnChoice = ""
lcPrnChoice = GETPRINTER()
IF EMPTY(lcPrnChoice)
RETURN ""
ELSE
*** Include quotes around the printer name
*** in case there are spaces in the name
lcPrnChoice = "NAME [" + lcPrnChoice + "]"
SET PRINTER TO &lcPrnChoice
RETURN lcPrnChoice
ENDIF
ENDIF
ENDFUNC

Msacces stored query and delphi using ado error

I have prepared this query in access and it is working ok.
SELECT Kod, Unvan, CepTel, Telefon, (SELECT Sum(Borc.Tutar) from borc
where carikod=kod) AS BorcTutar, (SELECT Sum(Alacak.Tutar) from Alacak
where carikod=kod) AS AlacakTutar
FROM cari;
But when want to use query in delphi i have to use serverside corsorlocation and static cursor.
Then delphi throw an exception and says "e-fail" , "invalid argument" and diffrent kind of messages when i change the cursor locations and types..
It is working wit clientside cursor but return 0 for sum()..
How to use correctly this query...
I have converted the "amount" fields the currency, then delphi choose correct type for them (tbcdfield beside tintegerfield)....
report is working now

Resources