code-conversion

Delphi - XE2 code to Delphi7 needed. Using wininet to download a file

╄→尐↘猪︶ㄣ 提交于 2019-12-13 19:23:17
问题 Note: I only want to use wininet, not urlmon-urldownloadtofile. Well, I have the following code which works perfectly in XE2 to download a file: procedure DownloadFile(URL: string; Path: string); const BLOCK_SIZE = 1024; var InetHandle: Pointer; URLHandle: Pointer; FileHandle: Cardinal; BytesRead: Cardinal; DownloadBuffer: Pointer; Buffer: array [1 .. BLOCK_SIZE] of byte; BytesWritten: Cardinal; begin InetHandle := InternetOpen(PWideChar(URL), 0, 0, 0, 0); URLHandle := InternetOpenUrl

How to Convert This C# Event/Delegate Code Into VB.NET (2008 or 2010)

拟墨画扇 提交于 2019-12-13 07:58:33
问题 C# to VB.NET Here is the relevant C# Code namespace MyApp { public delegate bool AllocHandlerDelegate(int param1); public interface ILoader { event AllocHandlerDelegate evAlloc; bool Load(); } public class MyLoader : ILoader { public event AllocHandlerDelegate evAlloc; public bool Load() { try { if (this.evAlloc != null && !evAlloc(1)) return false; } } } Here is what I came up with so far. The C# delegate is a function which returns a boolean result. So I converted the delegate definition

Map JSON response from Ruby to Python

巧了我就是萌 提交于 2019-12-11 14:39:57
问题 [EDIT]: Sorry I didn't explain in enough details the first time as I kind of wanted to figure the rest out for myself, but I ended up confusing myself even more I have a small problem. I wanted to take advantage of a website's API JSON response { "Class": { "Id": 1948237, "family": "nature", "Timestamp": 941439 }, "Subtitles": [ { "Id":151398, "Content":"Tree", "Language":"en" }, { "Id":151399, "Content":"Bush, "Language":"en" } ] } So I'd like to print the url with a combined string of each

How to select range of columns in a dataframe based on their name and not their indexes?

别等时光非礼了梦想. 提交于 2019-12-11 05:08:20
问题 In a pandas dataframe created like this: import pandas as pd import numpy as np df = pd.DataFrame(np.random.randint(10, size=(6, 6)), columns=['c' + str(i) for i in range(6)], index=["r" + str(i) for i in range(6)]) which could look as follows: c0 c1 c2 c3 c4 c5 r0 2 7 3 3 2 8 r1 6 9 6 7 9 1 r2 4 0 9 8 4 2 r3 9 0 4 3 5 4 r4 7 6 8 8 0 8 r5 0 6 1 8 2 2 I can easily select certain rows and/or a range of columns using .loc : print df.loc[['r1', 'r5'], 'c1':'c4'] That would return: c1 c2 c3 c4 r1

Rewrite part of javascript with C#

ⅰ亾dé卋堺 提交于 2019-12-11 02:44:13
问题 I'm writing this program in C# which should display Google Maps. I'm using the Google Maps JavaScript API which is the best one I could find. With the program you should be able to search for places. The code: window.onload = function() { var latlng = new google.maps.LatLng(52.785804, 6.897585); var options = { zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map"), options); } html, body { margin: 0; width: 100%;

How do you convert C++ _tcscpy, _tcscat to Delphi?

◇◆丶佛笑我妖孽 提交于 2019-12-08 20:05:43
I'm converting this code from C++ to Delphi but I don't get the following part of the code. Can anyone explain me what the following code means; what's happening to the szBuff buffer ? I'm pretty sure it's such kind of formatting (replacement), but I don't even know what is expected as a result and I can't find any sensible documentation of the used functions (maybe I'm just a lame :) Can anyone help me with the translation of this code to Delphi (or direct me to proper documentation) ? I don't like this how do you convert kind of questions by myself, so I mentioned at least function names in

How do you convert C++ _tcscpy, _tcscat to Delphi?

孤街浪徒 提交于 2019-12-08 07:44:55
问题 I'm converting this code from C++ to Delphi but I don't get the following part of the code. Can anyone explain me what the following code means; what's happening to the szBuff buffer ? I'm pretty sure it's such kind of formatting (replacement), but I don't even know what is expected as a result and I can't find any sensible documentation of the used functions (maybe I'm just a lame :) Can anyone help me with the translation of this code to Delphi (or direct me to proper documentation) ? I don

How can I complete this Objective-C implementation of a cartesian product function?

為{幸葍}努か 提交于 2019-12-07 03:54:52
问题 As a follow up to my question here, I am trying to implement the following PHP function in Objective-C, which will generate a cartesian product: function array_cartesian_product($arrays) { $result = array(); $arrays = array_values($arrays); $sizeIn = sizeof($arrays); $size = $sizeIn > 0 ? 1 : 0; foreach ($arrays as $array) $size = $size * sizeof($array); for ($i = 0; $i < $size; $i ++) { $result[$i] = array(); for ($j = 0; $j < $sizeIn; $j ++) array_push($result[$i], current($arrays[$j]));

Build native c++ for use as .net library

可紊 提交于 2019-12-06 12:35:39
问题 I have the c++ source code of functionality which is appealing to me. What effort/work is involved/required in order to either reference this from a .net application or build this code as a .net assembly (preferably c#)? This is my first attempt at porting code, so please breakdown your answer for me step by step. 回答1: There are several ways of doing it. PInvoke Create C++/CLI wrapper around your C++ native code (make static library out of C++ native code) and C++/CLI generated assembly can

How can I complete this Objective-C implementation of a cartesian product function?

给你一囗甜甜゛ 提交于 2019-12-05 06:26:00
As a follow up to my question here , I am trying to implement the following PHP function in Objective-C, which will generate a cartesian product: function array_cartesian_product($arrays) { $result = array(); $arrays = array_values($arrays); $sizeIn = sizeof($arrays); $size = $sizeIn > 0 ? 1 : 0; foreach ($arrays as $array) $size = $size * sizeof($array); for ($i = 0; $i < $size; $i ++) { $result[$i] = array(); for ($j = 0; $j < $sizeIn; $j ++) array_push($result[$i], current($arrays[$j])); for ($j = ($sizeIn -1); $j >= 0; $j --) { if (next($arrays[$j])) break; elseif (isset ($arrays[$j]))