Debugging: Unable to reveal the value of the TStrings - delphi

In my debugging, I tried to get Delphi to reveal or expose the value of FTestResult (TStrings). The Delphi's debugger shows in "FTestResult ()" in watch window.
private
FTestThread:TTestThread;
FTestState:TState;
FTestResult:TStrings; //represent a list of strings.
........
........
FTestResult.Clear();
FTestResult.Add('EmployeeId=''' + TMainForm(Application.MainForm).UserId.Text + '''');
........
Is this normal if it produces nothing in () after add?
Please advise... Thanks

Is this normal if it produces nothing in () after calling Add?
Yes this is the expected behaviour. Delphi 7 does not have a bespoke debugger visualizer for TStrings. This functionality was added in Delphi 2010. You'll have to find some other way to inspect the contents of this object in Delphi 7.
The () is the output of the standard visualizer for an instance of a class. Inside the parens are the data members, of which TStrings has none.

Related

Delphi 2007 - Compile errors on updating Indy from 10.5.1.1 to 10.6.2.0

I recently updated the stock Indy that installs with Delphi 2007 (I think it is 10.5.1.1) with 10.6.2.0, which I downloaded from GitHub.
I'm now getting a compile error:
EAttachmentFileNotFound.IfFalse (FileExists (parActualAttachmentFileID), 'File ' + parActualAttachmentFileID + ' not found.') ;
Error: E2003 Undeclared identifier: 'IfFalse'
The fragment is from my own code but I'm pretty sure that bit came from something I found probably on S/Overflow.
I received a couple of other errors also:
SMTPClient.AuthType := atDefault ;
Error: E2003 Undeclared identifier: 'atDefault'
and
SMTPClient.OnWork := EmailThread.EmailOnWork ;
Error: E2010 Incompatible types: 'Int64' and 'Integer'
but the first is a member that was renamed, and the second a data type that was changed. While these were a simple enough workaround, I'm left wondering
whether there was ever a "breaking changes" document generated.
maybe I accidentally somehow got the wrong source set.
EAttachmentFileNotFound is not a standard Indy exception, so it must be coming from your own code, or another 3rd party library.
Delphi 2007 was released almost 16 years ago. A lot has changed in Indy during that time. In fact, I think the changes you mention were actually made prior to, or maybe around, the release of Delphi 2007 (as they already existed in Indy's code in early 2008).
For instance:
in EIdException, the If(True|False) methods were removed (I don't know when exactly that change happened). In which case, you will have to use your own if and raise expressions now, eg:
if not FileExists(parActualAttachmentFileID) then
raise EAttachmentFileNotFound.Create('File ' + parActualAttachmentFileID + ' not found.');
in TIdComponent, the AWorkCount/Max parameters of the OnWork... events were changed from Integer to Int64 in 2006 (see OnWork Events changed to 64 bit on Indy's blog).
in TIdSMTP, the atDefault value was renamed to satDefault (again, I don't know exactly when this change was made).
So, you need to update your code accordingly.
I'm left wondering whether there was ever a "breaking changes" document generated.
No such document was ever created, no. However, changes that affect user code are typically announced on Indy's blog, under the Changelog category.

Compiler error using TDateTime EncodeTime function

I am using C++Builder 10.3.2 Community Edition on Windows 10 Home Version 1903.
I tried to use Remy's code below to get the UTC date/time.
When compiling, bcc32c issues an error:
no matching function for call to 'EncodeTime'.
The call to EncodeDate is valid.
I've used exactly the same code in C++Builder 5 on Vista and it works fine.
I've been trying to find a reference to this problem without success. Am I missing something?
TDateTime __fastcall NowUTC(void)
{
SYSTEMTIME SystemTime;
::GetSystemTime(&SystemTime);
return EncodeDate(SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay) + EncodeTime(SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond);
}
The EncodeTime needs milli-seconds added. Try this line:
return EncodeDate(SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay)+ EncodeTime(SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond,SystemTime.wMilliseconds);

when run "printui.exe /s",it return error code 33 (error_lock_acess),how to fix it?

On Windows 7, I wantta open "print server property dialog" by printui.exe.in Delphi code :
a := 'printui.exe /s';
showMessage(inttostr(winexec(PChar(a),5)));
pls,how to fix it?thx.BTW ,it is work very well when type command this :
printui.exe /s
in cmd.exe.
When WinExec returns return code 33 it actually means that the call to winexec was a sucsess. In fact any return value greater than 31 means sucsess.
WinExec function documentation
The error code 33 error_lock_access that you are mentioning in the title is actually a System Error Code not a return value of WinExec function itself
System Error Codes (0-499)
Also as you can read in WinExec documentation under Security remarks it is actually not recomended to be useing WinExec but instead using CreateProcess due to possible security vulnerability of WinExec function.

123 ERROR_INVALID_NAME after activate Wave audio liverecorder

I am using the wave audio component in my project and I run into a problem that I am unable to resolve.
I am using Delphi XE 5 and my operating system is Windows 8. When I am trying to the run the project and active the liveaudio recorder on Windows 7, I got this: error Exception EOSError in module Chatproject.exe at 00029633. System Error. Code: 123. The filename, directory name, or volume label syntax is incorrect. But its working normal on Windows 8,. I tried to debug and figure out the problem I got this error message when I am activating the recorder
Update of the question :
i debugged each of sendtocl , sendbuffer ,buffer^, buffersize and here is result in the image ,, but i have no idea how to fix sendbuffer and buffer^ and sendtocl
http://i.stack.imgur.com/5sZ05.jpg
You have four references to sendtocl:
#56: sendtocl: TIdUDPClient;
#235: if sendtocl.active then
#236: sendtocl.SendBuffer(RawToBytes(Buffer^, Buffersize))
#260: sendtocl.Broadcast(usertype.Text, 12000);
It should be getting created when the form is created, assuming it's a component dropped on the form. But for whatever reason, it isn't instantiated at some point.
This is consistent with the exception message you're getting.
The ERROR_INVALID_NAME is probably pointing to an invalid URI, path, or filename -- it's entirely possible that it's valid in Win 8 but not Win 7. So when you try to invoke .Active, it fails. But why sendtocl woudl be set to NIL doesn't make sense. Mabye the exception is on the SendBuffer method?
As Ken suggests, you just need to go in with the debugger and figure out what's going on. I'm not sure there's much more us "out here" can do for you other than comment on how the code appears.

Why does the compiler say "statement expected, but expression of type '<x>' found"?

I googled around and found a way to set the mouse cursor position in Delphi.
Here is my code example:
SetCursorPos(100,100);
It's simple, but not working. Delphi gives me the error
"statement expected,but expression of type 'longbool' found"
I am getting the same error with this command:
PostMessage(wb1.Handle,WM_KEYDOWN, VK_RIGHT,0);
where wb1 is my TWebBrowser component.
Any ideas?
You have probably disabled a feature called "Extended syntax", which (among other things) allows you to use function calls like procedure calls. You can re-enable this feature in the project's options dialog.

Resources