From b44b5f9cd02c44563ddd8b71c6fc0f9ddf1ff075 Mon Sep 17 00:00:00 2001 From: Alan Seiden Date: Fri, 9 Feb 2024 17:44:29 -0500 Subject: [PATCH] Create data-structure.php --- samples/data-structure.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 samples/data-structure.php diff --git a/samples/data-structure.php b/samples/data-structure.php new file mode 100644 index 0000000..5d4ca8a --- /dev/null +++ b/samples/data-structure.php @@ -0,0 +1,21 @@ +// Data structure is easy to add. It's just another parameter. + +$param = []; // initialize parameter array + +// add parameters as desired +$param[] = $tk->AddParameterChar('in', 10,'Name', 'PTNAME', 'Fred'); +$param[] = $tk->AddParameterChar('in', 25,'Address', 'PTADDR', '123 Toolkit Drive'); + +// DATA STRUCTURE +// Define the data structure as an array of basic parameter types or other data structures +$ds = []; +$ds[] = $tk->AddParameterChar('in', 21,'Part', 'PTPRT', 'A123'); +$ds[] = $tk->AddParameterChar('in', 3,'Vendor', 'PTVEN', '825'); +$ds[] = $tk->AddParameterChar('out', 20,'Description', 'PTDES', $out); +$ds[] = $tk->AddParameterZoned('out', 9, 2, 'Price', 'PTPRC', $out); + +// Add the data structure as just another element in your main parameter array. +$param[] = $tk->AddDataStruct($ds, 'myds'); + +// Add additional regular parameters as needed +$param[] = $tk->AddParameterZoned('in', 5, 2, 'Discount', 'PTDISC', '0.24');