![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) Impossible Execution PlanSee more CURL ExamplesThis example demonstrates what happens when it is not possible to construct an execution plan due to missing dependencies. The target When When This example highlights that for an execution plan to be valid, every required input must either:
If neither condition is met, the system correctly detects the unresolved dependency and prevents execution. Note: This example requires Chilkat v11.5.0 or greater. For more information, see https://www.chilkatsoft.com/curl_dependency_engine.asp
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, JsonObject, HttpCurl; ... procedure TForm1.Button1Click(Sender: TObject); var success: Boolean; httpCurl: HCkHttpCurl; targetCurl: PWideChar; fnName: PWideChar; planJson: HCkJsonObject; begin success := False; success := False; httpCurl := CkHttpCurl_Create(); // This target curl command requires {{drive_id}}. targetCurl := 'curl -X GET https://graph.microsoft.com/v1.0/drives/{{drive_id}}/root/children'; // Define a helper function that can produce site_id. // However, it does NOT produce drive_id. fnName := 'getSite'; CkHttpCurl_AddFunction(httpCurl,fnName,'curl -X GET https://graph.microsoft.com/v1.0/sites/root:/sites/{{site_name}}'); CkHttpCurl_AddOutput(httpCurl,fnName,'id','site_id'); // Provide site_name, so getSite can run. CkHttpCurl_SetVar(httpCurl,'site_name','test'); // Try to examine the execution plan. // This fails because {{drive_id}} is required by the target curl command, // but drive_id is not already known and no defined function produces it. planJson := CkJsonObject_Create(); CkJsonObject_putEmitCompact(planJson,False); success := CkHttpCurl_ExaminePlan(httpCurl,targetCurl,planJson); if (success = False) then begin // Should equal 5. Memo1.Lines.Add('ExaminePlan fail reason = ' + IntToStr(CkHttpCurl_getFailReason(httpCurl))); // Examine the error(s) returned in planJson Memo1.Lines.Add(CkJsonObject__emit(planJson)); // Expected output: // { // "errors": [{ // "variable": "drive_id", // "msg": "No candidate functions" // }] // } end; // DoYourThing will fail for the same reason. success := CkHttpCurl_DoYourThing(httpCurl,targetCurl); // We expect DoYourThing to fail because it is not possible to construct // a valid execution plan (drive_id cannot be resolved). if (success = False) then begin // FailReason provides a numeric code indicating why the operation failed. // A value of 5 specifically means that an execution plan could not be created // due to unresolved dependencies (i.e., a required variable has no source). Memo1.Lines.Add('DoYourThing fail reason = ' + IntToStr(CkHttpCurl_getFailReason(httpCurl))); end else begin // If execution succeeds, it means the plan was somehow resolved, // which would be unexpected in this scenario. Memo1.Lines.Add('Unexpected success.'); end; CkHttpCurl_Dispose(httpCurl); CkJsonObject_Dispose(planJson); end; |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.