PHP WinBinder 4: Coding: Difference between revisions

m
no edit summary
(New page: {{Nav PHP WinBinder 4}} '''''WinBinder Part 4 - Coding''''' == Introduction == Our tray-menu contains unresolved details such as what elements to include in the master array and configurat...)
 
mNo edit summary
 
Line 70: Line 70:
; Comments start with ';', as in php.ini
; Comments start with ';', as in php.ini


title = "US Menu"                    ; Manin application name
title = "US Menu"                    ; Main application name


[main_menu]
[main_menu]
Line 199: Line 199:


     $cmd5 = $cmd1.$cmd2.$cmd3.$cmd4;      // build command string
     $cmd5 = $cmd1.$cmd2.$cmd3.$cmd4;      // build command string
     pclose(popen($cmd5,'r'));              // Run a detatched process
     pclose(popen($cmd5,'r'));              // Run a detached process
   }
   }


Line 210: Line 210:


     $cmd6 = $cmd1.$cmd2.$cmd3.$cmd4.$cmd5; // build command string
     $cmd6 = $cmd1.$cmd2.$cmd3.$cmd4.$cmd5; // build command string
     pclose(popen($cmd6,'r'));              // Run a detatched process
     pclose(popen($cmd6,'r'));              // Run a detached process
   }
   }
}
}
Line 226: Line 226:
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
==== (PHP CLI) relative to absolute path conversion function ====
==== (PHP CLI) relative to absolute path conversion function ====
The following function converts any relative paths in a string to absolute paths. It assumess relatives paths are relative to the script.
The following function converts any relative paths in a string to absolute paths. It assumes relatives paths are relative to the script.


{|
{|
Line 242: Line 242:
$str = trim($str);                                        // Remove L&R spaces
$str = trim($str);                                        // Remove L&R spaces
$str = preg_replace('/\s+/', ' ', $str);                  // Remove double spaces
$str = preg_replace('/\s+/', ' ', $str);                  // Remove double spaces
$str_array  = explode(" ",$str);                        // Blow string appart at " "  
$str_array  = explode(" ",$str);                        // Blow string apart at " "  


for($i = 0; $i < count($str_array); $i++) {                // scan str array line by line
for($i = 0; $i < count($str_array); $i++) {                // scan str array line by line
Line 292: Line 292:
//=== Array Insert =============================================================
//=== Array Insert =============================================================
function array_insert(&$array, $insert, $position = -1) {  
function array_insert(&$array, $insert, $position = -1) {  
  $position = ($position == -1) ? (count($array)) : $position ;  
  $position = ($position == -1) ? count($array) : $position ;  
  if($position != (count($array))) {                      // Is it end of array  
  if($position != count($array)) {                      // Is it end of array  
       $ta = $array;                                      // New array   
       $ta = $array;                                      // New array   
       for($i = $position; $i < (count($array)); $i++) {  // Scan array
       for($i = $position; $i < (count($array)); $i++) {  // Scan array
2

edits