File: f_setplatform.srf
Size: 3247
Date: Tue, 22 Jan 2008 23:28:50 +0100
$PBExportHeader$f_setplatform.srf
$PBExportComments$PFC Plaform service Create/Destroy
global type f_setplatform from function_object
end type

forward prototypes
global function integer f_setplatform (ref n_cst_platform anv_platform, boolean ab_switch)
end prototypes

global function integer f_setplatform (ref n_cst_platform anv_platform, boolean ab_switch);//////////////////////////////////////////////////////////////////////////////
//
// Function:      f_SetPlatform
//
// Access:        public
//
// Arguments:  
// anv_Platform   User Object of type n_cst_platform that will be created - passed by reference
// ab_Switch      True - start (create) the object
//                False - stop (destroy) the object
// 
// Returns:       Integer
//                 1 - Successful operation.
//                 0 - No action taken.
//                -1 - An error was encountered.
//
// Description:  Creates/Destroys the Cross Platform object
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0   Initial version
// 5.0.02 Added support for Macintosh, Solaris, and Windows NT.
// 5.0.02 Added argument and error checking.
// 5.0.03 Fixed Creation of 16 bit service for 16 bit exe running under NT
// 6.0   Added support for Unix version on AIX (IBM) and HPUX (HP)
// 6.0.02 Added support for Unicode.
// 7.0 Removed support for 16-bit and Macintosh services
//
//////////////////////////////////////////////////////////////////////////////
//
/*
 * Open Source PowerBuilder Foundation Class Libraries
 *
 * Copyright (c) 2004-2005, All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted in accordance with the GNU Lesser General
 * Public License Version 2.1, February 1999
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals and was originally based on software copyright (c) 
 * 1996-2004 Sybase, Inc. http://www.sybase.com.  For more
 * information on the Open Source PowerBuilder Foundation Class
 * Libraries see http://pfc.codexchange.sybase.com
*/
//
//////////////////////////////////////////////////////////////////////////////

// Argument and error checking.
If IsNull(ab_switch) Then Return -1
If IsNull(gnv_app) Or Not IsValid(gnv_app) Then Return -1

if ab_switch then
   if IsNull (anv_platform) or not IsValid (anv_platform) then
      // create platform object based on platform
      choose case gnv_app.ienv_object.ostype
         case windows!, windowsnt!
            if gnv_app.ienv_object.CharSet = charsetunicode! then
               anv_platform = create n_cst_platformunicode
            else
               anv_platform = create n_cst_platformwin32
            end if
         case sol2!
            anv_platform = create n_cst_platformsol2
         case hpux!
            anv_platform = create n_cst_platformhpux
         case aix!
            anv_platform = create n_cst_platformaix
         case else
            anv_platform = create n_cst_platform
      end choose
      return 1
   end if
else
   if IsValid (anv_platform) then
      destroy anv_platform
      return 1
   end if
end if

return 0
end function