How to insert working TAB char on Windows 7? - delphi

I use the following to show a messagebox where I would like some info to be alligned using a TAB char.
This is working OK on Windows XP but not on Windows 7 (I have no Windows 8 to test).
ShowMessage(lSearch + sLineBreak +
'Breddegrad: ' + Chr(9) + HAMInfo.Latitude + sLineBreak +
'Længdegrad: ' + Chr(9) + HAMInfo.Longitude + sLineBreak +
'QRA locator: ' + Chr(9) + HAMInfo.Qra);
What other options are there if this can't be fixed to work on Windows 7?
Delphi XE3

The other variant is using ShowMessageFmt or using format function explicitly before calling ShowMessage.
But due to default fonts being proportional rather than fixed-width, it would still not result in a fine equal alignment.
http://www.delphibasics.co.uk/RTL.asp?Name=ShowMessageFmt
http://delphi.about.com/library/rtl/blrtlShowMessageFmt.htm
.
ShowMessageFmt('%s'#13#10 +
'%-16s%s'#13#10 + '%-16s%s'#13#10 + '%-16s%s',
[ lSearch , 'Breddegrad:', HAMInfo.Latitude,
'Længdegrad:', HAMInfo.Longitude,
'QRA locator:', HAMInfo.Qra ] );

Related

CoreML : "Unexpected error processing model" error sometimes occurring

Context:
I'm using a custom CoreML model made by a datascientist.
The model is a pipeline that uses Apple SoundAnalysisPreprocessing model as it's first model. SoundAnalysisPreprocessing model is followed by a custom model that contains different convolution layers and a softmax.
Issue:
When launching a prediction, I sometimes get Unexpected error processing model. With the exact same input, I sometimes get a correct result and sometimes I get this error.
Question: I have no clue what to do with this error. Is it a memory problem with input being badly allocated ? Is it a problem with the model itself ?
Do you have any idea what I could do to understand what is happening ?
Complete error log:
[DSPGraph] throwing DSPGraph::Exception with backtrace:
0 0x7fff2bcf5df9 DSPGraph::Graph::processMultiple(DSPGraph::GraphIOData*, DSPGraph::GraphIOData*) + 249
1 0x7fff2bc3b570 processThroughGraph(id<MLFeatureProvider>, MLMultiArrayConstraint*, MLMultiArray*, NSString*, DSPGraph::Graph&, std::__1::vector<float, DSPGraph::Graph&::allocator<float> >&, void (DSPGraph::Graph, NSString*::GraphIOData&) block_pointer, NSError* __autoreleasing*) + 979
2 0x7fff2bc3c573 -[SNDSPGraphCustomModel predictionFromFeatures:options:error:] + 195
3 0x7fff2bc3ca49 -[_SNVGGishFrontEndProcessingCustomModel predictionFromFeatures:options:error:] + 98
4 0x7fff2496ac30 -[MLAppleSoundAnalysisPreprocessing predictionFromFeatures:options:error:] + 132
5 0x7fff248d345c -[MLPipeline predictionFromFeatures:options:error:] + 178
6 0x7fff24923f76 -[MLModel predictionFromFeatures:error:] + 92
7 0x104b89a68 $s10TestCoreML17AudioFileAnalyzerC019previsionWithManualD3Cut33_1966162A0510E69792A8D979B37CC177LL3for10completiony10Foundation3URLV_ySo12MLMultiArrayCSgXEtF + 5992
8 0x104b87850 $s10TestCoreML17AudioFileAnalyzerC05startF03for10completiony10Foundation3URLV_yyXEtF + 80
9 0x104bb360c $s10TestCoreML23ClassificationViewModelC14startRecognize4word8mockData11resultBlock06finishM0ySS_SbySb_SaySo16SNClassificationCGSgtcSgyyctF + 3436
10 0x104bad21c $s10TestCoreML18ReadViewControllerC010collectionE0_15didSelectItemAtySo012UICollectionE0C_10Foundation9IndexPathVtFyycfU_ + 220
11 0x104b923fd $sIeg_IeyB_TR + 45
12 0x104f79d64 _dispatch_client_callout + 8
13 0x104f7c6d6 _dispatch_continuation_pop + 552
14 0x104f8fa8f _dispatch_source_invoke + 2205
15 0x104f87c53 _dispatch_main_queue_callback_4CF + 1043
[truncated?]
2019-10-30 20:33:04.209693+0100 TestCoreML[5024:191792] [] Caught graph exception 1718775073 !mrf fromBytePos (0) + numBytesToCopy (61440) > mABL->mBuffers[0].mDataByteSize (2112) in /BuildRoot/Library/Caches/com.apple.xbs/Sources/Listen_Sim/Listen-35/CoreAudioUtility/Source/CADSP/DSPGraph/DSPGraph_Utils.cpp:742
I believe you need to update some of the libs in your code. Based on this GitHub related to your error.
Github
graph exception 1718775073 is the key.
In the forum they said this was the fix, because of a weird difference in between incoming call vs outgoing call variables.
if (-0.01f <= hw_srate || hw_srate >= 0.1.f)
{
fmt.mSampleRate = prm->state;
fat->sample_rate = 1.0f;
}
To resolve this you have to manually move the model file into the app directory and then add it to xcode - it seems to be a bug in Xcode putting the model that is stored in another directory into the app package

Scrolling script for iOS 10 with Appium java client 5.0.0 and Appium version 1.6.4

Actually I know this will work for iOS 9.3 or below:
findElementByIosUIAutomation(".scrollToElementWithPredicate(\"name CONTAINS '" + text + "'\")");
But I want to do it for iOS 10 and looking for the scrolling script with
findElementByIosNsPredicate("????")
Using Appium 1.6.4 with java client 5.0.0 Beta 7
try this:
WebElement element = this.findElementByIosNsPredicate("name matches '"+ elementName + "'");
new TouchAction(driver).press(element, 0, 0).moveTo(element, 0, 0).release().perform();

Delphi XE7 crashses at shutdown

Since I installed Delphi XE7 I have this nasty crash as shutdown:
Description:
Stopped working
Problem signature:
Problem Event Name: APPCRASH
Application Name: bds.exe
Application Version: 21.0.17707.5020
Application Timestamp: 545bd62d
Fault Module Name: rtl210.bpl
Fault Module Version: 21.0.17707.5020
Fault Module Timestamp: 545bd940
Exception Code: c0000005
Exception Offset: 00016a9c
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033
After I click the 'Close program' I get:
Exception EAccessViolation in module rtl210.bpl at 00016A9C.
Access violation at address 50066A9C in module 'rtl210.bpl'. Read of
address 075F2AF8.
I checked the call stack but it doesn't really makes any sense.
To see the call stack I started Delphi, then in 'Load process' I entered Delphi's path ( "C:\Delphi\XE7\bin\bds.exe" ).
I cannot set the '-p delphi' parameter in 'Parameters' box because when the second Delphi process is started it will complain that it cannot access the license file (which is blocked by the first Delphi process).
Call stack:
:50066a9c rtl210.#System##IntfClear$qqrr44System#%DelphiInterface$17System#IInterface% + 0x10
:08baffdd fmx210.#System#Generics#Collections#%TList__1$56System#%DelphiInterface$29Fmx#Behaviormanager#IListener%%#SetCount$qqri + 0x49
:50061099 rtl210.#System##Halt0$qqrv + 0xb1
:77378bd4 ntdll.wcsncmp + 0x88
:77342710 ; ntdll.dll
:7737cb10 ntdll.LdrUnloadDll + 0x4a
:753b8be4 KERNELBASE.FreeLibrary + 0x82
:2063a191 coreide210.#Exptmain#TExpertLib#$bdtr$qqrv + 0xa9
:5005f10b rtl210.#System#TObject#Free$qqrv + 0xb
:5070ba40 vcl210.#Vcl#Forms#TCustomForm#$bdtr$qqrv + 0x58
:210f57c0 designide210.#Deskform#TDesktopForm#$bdtr$qqrv + 0x40
:761aee1c kernel32.BaseThreadInitThunk + 0x12
:7738399b ntdll.RtlInitializeExceptionChain + 0xef
:7738396e ntdll.RtlInitializeExceptionChain + 0xc2
It says something about FMX but I never do FMX projects (still too unripe to be used). So I disable it.
What could cause the crash?
This is a Delphi bug
SOLUTION: Enable 'FMX Standard Components' package.
Details: I turned out that I had the 'FMX Standard Components' package disabled - Seems logical to disable such a large library since I don't use it.
Well... Delphi don't like that! I enabled the library back and now I have no crash!
I could have delete the question since nobody answered posted any answer but I thought it will be useful to keep it. It documents a very important feature of Delphi: crash when the developer won't use FMX lib :)

Add File Summary tab data in runtime in NTFS in WinXP SP3

I have given up tryng to figure out the reason of this issue, but here is the story and hope you could give a tip...
As I develop unique app ( http://code.google.com/p/sedev ) and therefore I need to polish it.
I have to add File Summary ( very useful info in my opinion ) to any created files by the app, so I decided to go with NTFS compatible structure
edit: code snippet in which problem occurs:
if (FileExists(BaseLocation + LeftStr(GetSSWData, Length(GetSSWData)
- 1) + '.vkp') = True) then // add NTFS descriptive information to output file
try
SetFileSummaryInfo
(PWideChar(BaseLocation + LeftStr(GetSSWData, Length
(GetSSWData) - 1) + '.vkp')); // in my testcase files full path is: C:\Documents and Settings\Kludge\Desktop\sedevrpg\SEDEV_RPG_O_710.vkp
ShowMessagePos('Patch Created successfuly!' + #13#13 +
'Please verify created data to www.se-developers.net.',
ParamStr2X, ParamStr3Y);
MessageBeep(0);
except // exception handler does not even fire on exception ...
on Exception do
begin
if (WarningChBx.Checked = True) then
ShowMessagePos
('Unable to add Description to Output file (' +
BaseLocation + LeftStr(GetSSWData, Length(GetSSWData)
- 1) + '.vkp )', ParamStr2X, ParamStr3Y);
MessageBeep(0);
end;
end
final edit by author: Problem was in SetFileSummaryInfo(PWideChar('')) because after PWideChar conversion you got CHARACTER, not Array of Characters ( aka Strings ) therefore it is not valid path anymore!
Here is main tutorial: http://www.delphipages.com/articles/setting_file_summary_information-9228.html
edit: a better formatted tutorial is here.
BUT, the thing is that I just cannot get that damned FileName param to accept any string ... I have EOleSysError exception: "%1 cannot be found" no matter what.
Faulting operand is:
OleCheck(StgOpenStorageEx(PWideChar(FileName),
STGM_SHARE_EXCLUSIVE or STGM_READWRITE,
STGFMT_ANY,
0, nil, nil, #IID_IPropertySetStorage, stg));
What I do not understand is why it actually wants %1 MSDOS file name input.
I am not launching app from CMD therefore I highly doubt it needs additional param for File path ...
I have tried all possible String and PString conversions, also tried various param passing methods ... It just does not work ...
Any help appreciated!
I can only reproduce your case by specifying an invalid filename. Make sure that you include the full path in your filename.

TApplicationEvents as dynamic component or static for tracing called routine in Delphi

Unfortunately I am not writing this question from my Developing PC so I might do some mistakes. Please sorry about it...
So - my question - what approach you use to implement error logging in your application?
In web ( http://delphi.about.com ) is nice event handler, but it just copies system error in file, but I would like to expand its capabilities by trapping memory and stack ( and processor information, if I will have time ). Should I aware if I call it dynamically, not adding its component on the form?
procedure TForm1.ApplicationEvents1Exception(Sender: TObject; E: Exception) ;
var
ErrorLogFileName : string;
ErrorFile : TextFile;
ErrorData : string;
begin
ErrorLogFileName := ChangeFileExt(Application.ExeName,'.error.log') ;
AssignFile(ErrorFile, ErrorLogFileName) ;
//either create an error log file, or append to an existing one
if FileExists(ErrorLogFileName) then
Append(ErrorFile)
else
Rewrite(ErrorFile) ;
try
//add the current date/time and the exception message to the log
ErrorData := Format('%s : %s',[DateTimeToStr(Now),E.Message]) ;
WriteLn(ErrorFile,ErrorData) ;
finally
CloseFile(ErrorFile)
end;
//Show the exception
Application.ShowException(E) ;
end;
... and http://delphi.about.com/cs/adptips2001/a/bltip0101_2.htm
As we know, Delphi also provides memory management a bit like C - using ampersands and Pascal functions, but what would be the most effective logging?
Thanks before! Hopefully this topic will be useful to other quality programmers.
Might be worth looking at third party components instead of writing something yourself. Both EurekaLog and madExcept do pretty much exactly what you're after. Both give great output and have support to connect into bug tracking systems like FogBugz, Mantis and BugZilla. With that you can actually collate the bug reports you're getting, spot common patterns and hopefully fix bugs quicker.
Personally, installing the Jedi JVCL / JCL is a bit overkill for just it's exception tracking since it's a fairly hefty install. Both of the above I've mentioned are commercial products, but you get what you pay for.
IIUC, you want a stack trace report with line numbers, system info etc. IOW something like this:
Exception class: EVariantTypeCastError
Exception address: 004170ED
------------------------------------------------------------------------------
Stack list, generated 12/7/2009 11:32:19
[004170E8]{A.exe } Variants.HandleConversionException (Line 614, "sys\variants.pas" + 10)
[0057ACAC]{A.exe } cxDataStorage.TcxSmallintValueType.SetDataValue (Line 1067, "cxDataStorage.pas" + 2)
[005AC6C5]{A.exe } cxCustomData.TcxCustomDataController.SetStoredValue (Line 12752, "cxCustomData.pas" + 2)
[005A8AD3]{A.exe } cxCustomData.TcxCustomDataController.SetValue (Line 10401, "cxCustomData.pas" + 12)
[0059DA0B]{A.exe } cxCustomData.TcxCustomDataProvider.SetEditValue (Line 3180, "cxCustomData.pas" + 4)
[005A8F9B]{A.exe } cxCustomData.TcxCustomDataController.SetEditValue (Line 10560, "cxCustomData.pas" + 2)
[0066EBBE]{A.exe } cxGridCustomTableView.TcxCustomGridTableItem.SetEditValue (Line 14396, "cxGridCustomTableView.pas" + 1)
[006637C5]{A.exe } cxGridCustomTableView.TcxGridEditingController.UpdateValue (Line 7474, "cxGridCustomTableView.pas" + 4)
[00673F30]{A.exe } cxGridCustomTableView.TcxCustomGridTableView.UpdateRecord (Line 17771, "cxGridCustomTableView.pas" + 1)
[0059D97F]{A.exe } cxCustomData.TcxCustomDataProvider.PostEditingData (Line 3170, "cxCustomData.pas" + 1)
[00A80870]{A.exe } fFilterLine.TFilterLine.UMLayoutChanged (Line 1034, "fFilterLine.pas" + 0)
[00482DBF]{A.exe } Controls.TWinControl.WndProc (Line 7304, "Controls.pas" + 111)
[004824E8]{A.exe } Controls.TWinControl.MainWndProc (Line 7073, "Controls.pas" + 3)
[00431D84]{A.exe } Classes.StdWndProc (Line 11583, "common\Classes.pas" + 8)
[0049F981]{A.exe } Forms.TApplication.MessageBox (Line 8293, "Forms.pas" + 22)
[0049FA99]{A.exe } Forms.TApplication.ShowException (Line 8312, "Forms.pas" + 3)
[00A7D7B1]{A.exe } ExceptionDlg.TfrmException.ExceptionHandler (Line 428, "..\Shared\ExceptionDlg.pas" + 2)
...
<snipped>
...
------------------------------------------------------------------------------
System : Windows XP Professional, Version: 5.1, Build: A28, "Service Pack 2"
Processor: Intel, Intel(R) Core(TM)2 Quad CPU Q6700 # 2.66GHz, 2666 MHz MMX 64 bits
Memory: 1043; free 196
Display : 1920X1200 pixels, 32 bpp
------------------------------------------------------------------------------
Active Controls hierarchy:
TcxCustomInnerTextEdit ""
TcxTextEdit ""
TcxGridSite ""
TcxGrid "cxgHeader"
TPanel "pnlMain"
TTabSheet "tshAccMov"
TPageControl "pcoMov"
TfrmMain "frmMain"
------------------------------------------------------------------------------
...well, imho, isn't worth to reinvent the wheel.
This has already been done and it's free. Download (if you haven't already) the JEDI's JVCL+JCL from SourceForge and install them. In File | New | Other | Delphi Files... you'll have a new item: 'Jcl Exception dialog for Delphi'.
And (imho) this is much more mature/advanced than you can do 'if you'll have time'. Also you can customize the generated Exception Handler to fit to your needs. There is also a support newsgroup for this. As an aside, IIRC, you need only the JCL for the dialog but I'm not sure. Also, you have also commercial options for this (madExcept, EurekaLog etc.) but these are only advanced Error Loggers while JVCL, besides that's free, will give you also over 600 components to play with.
HTH

Resources