There is no built-in Split function in Delphi, sometimes we need an easy way to perform string splitting just like PHP or Python does: “Hello World”.split(‘ ‘) would produce dynamic array ['Hello', 'World'].
In Delphi you can perform that in different way, for example using TStringList separated text behavior but you need maintenance the TStrings instance each time performing splitting.
var Temp: TStrings; begin Temp := TStringList.Create; try Temp.Text := StringReplace('Hello World', #32, #13#10, [rfReplaceAll]); // Process the list here // Temp = 'Hello' // Temp = 'World' finally Temp.Free; end; end;
Compare in Python way:
list = 'Hello World'.split(' ') # list == 'Hello' # list == 'World'
Pretty short and comfort is it.
I try makes something easy in Delphi way, like this:
var List: IStrings; begin List := SplitEx('Hello World', ' '); // List = 'Hello' // List = 'World'
Or more complex:
with SplitEx('08:00-13:00, '-') do begin // Index 0: 08:00 with SplitEx(Strings, ':') do // Index 0: 08 // Index 1: 00 dtStartTime.Time := EncodeTime(AsInt, AsInt, 0, 0); // Index 1: 13:00 with SplitEx(Strings, ':') do // Index 0: 13 // Index 1: 00 dtEndTime.Time := EncodeTime(AsInt, AsInt, 0, 0); end;
Forget Try-Finally to make sure your TObject instance destroyed completely on exit block procedure. TSafeMe makes your code clean without worrying with underlaying memory leaks.
Common try-finally pattern, is this your usual code?
function TXServer.ServiceDelete(const ServiceID: string): IXResponse; var Q_SERVICES: TORM_Q_SERVICES; begin Result := TXResponse.NewResponse(); Q_SERVICES := TORM_Q_SERVICES.Create; // create new instance try try Q_SERVICES.SERVICE_ID.WhereValue := ServiceID; Q_SERVICES.Controller.Delete; except on E: Exception do begin Result.RESP_CODE := RC_ERROR; Result.RESP_MSG := E.Message; end; end; finally Q_SERVICES.Free; // then relese it end; end;
Now compare with this one, see TSafeMe in action: Read more…
PowerLogic SDK is a framework that help you develop desktop application with Delphi more robust and fast, the successor are under development. PowerLogic consists of Delphi expert and modular framework itself.
Its main feature is the use of MDI interface, integrated with SSO (Single Sign On), the database access layer (with mini & fast ORM), and controller based architecture (plugin).
Debug your code directly under Delphi environment, no need to be changes, use your programming style and habit because you’re 100% coding in Delphi. Compile (CTRL+F9) and Run+Debug (F9) like usually… Everything configured to be works by the PowerLogic SDK Delphi expert.
With Delphi RAD you can create desktop-based applications quickly, with PowerLogic SDK you will be more rapid!
No need to think about the menus, deploying to the file server, versioning (auto update), and do not have to worry about authentication. All have been handled automatically, you just think the business logic.
PowerLogic SDK snaps.
I’m new using Python, also Bottle. After learning some frameworks I decide give a chance to Bottle as web framework. Default WSGIRefServer (for development) give me some lack while refresh http get from Google Chrome fast.
I think I need replace the default one: gevent. Searching anywhere found nothing about integrating Bootle on gevent. So here is mind, feel free to correct.
from bottle import Bottle, run, ServerAdapter myapp = Bottle() @myapp.route('/') def index(): return "Hello World" class GEventServer(ServerAdapter): """ Fast HTTP Server """ def run(self, handler): from gevent import monkey; monkey.patch_all() from gevent.wsgi import WSGIServer WSGIServer((self.host, self.port), handler).serve_forever() run(app=myapp, server=GEventServer, host='localhost', port=8080)
KSpoold Disinfector is a software that writen to restore Microsoft
Office files (Word, Excel, PPT etc.) from damaged file because of KSpoold virus.
KSpoold infect the docs files by mergeing these docs to the virus file,
original docs files will be delete & new file with the same name will be added
to cheating the users with new file extention: .EXE
So anytime you double click this infected file from explorer / open it using
shell api your computer will be infected too.
The software is provided “as-is,” without any express or implied warranty.
In no event shall the Author be held liable for any damages arising from
the use of the Software
The software is writen in Borland Delphi 7.
Full source-code also provided, any comments are noted of the following:
“The const SAMPLE_SIZE = 524; is taken from the following figure:
Microsoft Word & Excel using the same file header at the first 512,
so we get unique header at the first 12 byte after 512 offset
512 + 12 = 524 –> it’s my lucky number “
You can download sample of infected file by KSpoold here…
And the complete source & compiled program:
|Hosted by eSnips|