愛招飛幫助手冊 愛招飛幫助手冊
  • FastERP-1
  • Smart
  • PinToo
  • FastWeb
  • FastERP-2 企業管理系統 (opens new window)
  • 印染業ERP (opens new window)
  • 工廠終端機 (opens new window)
  • TARS
  • MARS
  • TaskRunner
  • Flying
  • FastDesk
  • HiDesk
  • HiNAT
  • FastBPM
  • 設備故障診斷 (opens new window)
  • 設備最佳運轉效益 (opens new window)
  • 企業智能助手SmeGPT (opens new window)
  • 燈號管理 (opens new window)
  • 戰情室 (opens new window)
  • 能源管理 (opens new window)
  • 人車定位 (opens new window)
  • 戰情指揮系統 (opens new window)
  • FastERP-1
  • FastWeb
  • Smart
  • PinToo
  • Flying
  • TARS
  • 通用功能

    • Report
    • Script
    • Echarts
    • Chart
    • DB Install
  • FastERP-1
  • Smart
  • PinToo
  • FastWeb
  • FastERP-2 企業管理系統 (opens new window)
  • 印染業ERP (opens new window)
  • 工廠終端機 (opens new window)
  • TARS
  • MARS
  • TaskRunner
  • Flying
  • FastDesk
  • HiDesk
  • HiNAT
  • FastBPM
  • 設備故障診斷 (opens new window)
  • 設備最佳運轉效益 (opens new window)
  • 企業智能助手SmeGPT (opens new window)
  • 燈號管理 (opens new window)
  • 戰情室 (opens new window)
  • 能源管理 (opens new window)
  • 人車定位 (opens new window)
  • 戰情指揮系統 (opens new window)
  • FastERP-1
  • FastWeb
  • Smart
  • PinToo
  • Flying
  • TARS
  • 通用功能

    • Report
    • Script
    • Echarts
    • Chart
    • DB Install
  • FastWeb幫助主頁
  • 學習手冊

    • 基本入門

    • 功能介紹

    • 控制元件說明

    • 系統工具

    • 系統管理

    • 云服務工具

    • 資料庫工具

    • 專用模板

    • 外部功能

    • 開發流程

    • 函式程式

      • 系統函式
      • 系統程式
      • 自定函式
        • 1. UGMM類函式
          • 1.1. ApplicationVersion
          • 1.2. CreateGuid
          • 1.3. CreateStringList
          • 1.4. DecodeString
          • 1.5. EncodeString
          • 1.6. Expexcel
          • 1.7. FileUpload
          • 1.8. GetObject
          • 1.9. GetWebSubForm
          • 1.10. GetAppSubForm
          • 1.11. GetBeanCaption
          • 1.12. GetBeanCode
          • 1.13. GetBeanToSql
          • 1.14. GetNodeDataLink
          • 1.15. GetRunFrame
          • 1.16. GetDesignFrame
          • 1.17. GetDesignFormatEditing
          • 1.18. GetDesignRestAPI
          • 1.19. GetFrameCaption
          • 1.20. GetLanguageByGrid
          • 1.21. GetLanguageByName
          • 1.22. GetUnitCode
          • 1.23. GetNavigRoleGuid
          • 1.24. GetNavigUserGuid
          • 1.25. GetNavigUserGuid
          • 1.26. GetDllComponent
          • 1.27. GetSessionList
          • 1.28. GetSQLCommand
          • 1.29. GetSQLCommandNodeName
          • 1.30. GetSQLCommandText
          • 1.31. GetWebSubForm
          • 1.32. HTTPDecode
          • 1.33. HTTPEncode
          • 1.34. ImpExcel
          • 1.35. LT
          • 1.36. LogInChecking
          • 1.37. SendWsMsg
          • 1.38. SendWsMsgBySId
          • 1.39. SendWsMsgByStr
          • 1.40. URLDownloadToFile
          • 1.41. VerifyRunFramePermType
          • 1.42. VerifyPermGuid
        • 2. UGSM類函式
        • 3. UGCM類函式
          • 3.1. AmountToChinese
          • 3.2. GetFileStreamFileName
          • 3.3. Gettamptime
          • 3.4. GettampTotime
          • 3.5. HexStrToStream
          • 3.6. HexToInt
          • 3.7. HexToBytes
          • 3.8. RoundToCH
          • 3.9. NetHttpGet
          • 3.10. NetHttpPost
          • 3.11. NetHttpPut
          • 3.12. NetHttpDelete
          • 3.13. GetJSONObject
          • 3.14. GetJSONArray
          • 3.15. GetJSONString
          • 3.16. GetJSONNumber
          • 3.17. GetJSONInteger
          • 3.18. GetJSONFloat
          • 3.19. GetJSONBool
          • 3.20. GetJSONValue
          • 3.21. ParseJSONValue
      • 自定程式
  • 開發手冊

目录

自定函式

# FastWeb 自定函式

  • 適用平臺:WEB(桌面),APP(移動)

# 1. UGMM類函式

  UGMM類函式在程式中呼叫時,必須以UGMM.開頭。

# 1.1. ApplicationVersion

Function ApplicationVersion:String;
1

說明: 獲取應用版本 返回值: 字元型別String

  • 示例
    //JScript
      UgLabel01.Caption = UGMM.ApplicationVersion;
    
    1
    2
    //PasScript
    begin
      UgLabel01.Cantion := UGMM.ApplicationVersion;
    End;
    
    1
    2
    3
    4
    // Make sure to add code blocks to your code group

    # 1.2. CreateGuid

    Function  CreateGuid:string;
    
    1

    說明: 建立GUID唯一編號 返回值: 字元型別String

    • 示例
      //JScript
        var vGuid;
        vGuid = UGMM.CreateGuid;
      
      1
      2
      3
      //PasScript
      var
       vGuid:string;
      begin
        vGuid := UGMM.CreateGuid;
      End;
      
      1
      2
      3
      4
      5
      6
      // Make sure to add code blocks to your code group

      # 1.3. CreateStringList

      Function CreateStringList(AEncoding:string='UTF8'):TStringList;
      
      1

      說明: 建立字串列表指定編碼型別 返回值: TStringList型別

      • CreateStringList 函式語法中各部分說明
      部分 說明
      AEncoding 指定編碼型別(UTF-7,UTF-8,UniCode)
      • 示例
        //JScript
          var vStrings;
          vStrings = UGMM.CreateStringList("UTF-8");
        
        1
        2
        3
        //PasScript
        var
         vStrings:TStringList;
        begin
         vStrings:=UGMM.CreateStringList('UTF-8');
        end;
        
        1
        2
        3
        4
        5
        6
        // Make sure to add code blocks to your code group

        # 1.4. DecodeString

        function DecodeString(AText:String):string;
        
        1

        說明: HTTP編碼 返回值: 字元型別String

        • DecodeString 函式語法中各部分說明
        部分 說明
        AText 指定需要解密的字串
        • 示例
          //JScript
            ShowMessage(UGMM.DecodeString("NW9pUjVwaXY1TGl0NVp1OTVMcTY3N3lCUkdWc2NHaHA="));
          
          1
          2
          //PasScript
          begin
            ShowMessage(UGMM.DecodeString('NW9pUjVwaXY1TGl0NVp1OTVMcTY3N3lCUkdWc2NHaHA='));
          End;
          
          1
          2
          3
          4
          // Make sure to add code blocks to your code group
          • 字串解密結果
          我是中國人!
          
          1

          # 1.5. EncodeString

          function EncodeString(AText:String):string;
          
          1

          說明: 字元加密 返回值: 字元型別String

          • EncodeString 函式語法中各部分說明
          部分 說明
          AText 指定需要加密的字串
          • 示例
            //JScript
              ShowMessage(UGMM.EncodeString("Hi,Hello"));
            
            1
            2
            //PasScript
            begin
              ShowMessage(UGMM.EncodeString('Hi,Hello'));
            End;
            
            1
            2
            3
            4
            // Make sure to add code blocks to your code group
            • 字串加密結果
            U0drc1NHVnNiRzg9UkdWc2NHaHA=
            
            1

            # 1.6. Expexcel

            function  ExpExcel(ADBGrid:TUgDBGrid;Const ACaption,ATitle:String):Boolean;
            
            1

            說明: 打開導出數據表至Excel的文字。 返回值: Boolean值

            • GetObject 函式語法中各部分說明
            部分 說明
            ADBGrid 指定一個TUgDBGrid類表格
            ACaption 指定導出對話方塊的標題
            ATitle 指定導出的表格的標題名稱
            • 示例
              //JScript
                UGMM.ExpExcel(gridFrames,UGMM.LT("模組列表(WEB)"),UGMM.LT("模組列表(WEB)"));
              
              1
              2
              //PasScript
                UGMM.ExpExcel(gridFrames,UGMM.LT('模組列表(WEB)'),UGMM.LT('模組列表(WEB)'));
              
              1
              2
              // Make sure to add code blocks to your code group

              # 1.7. FileUpload

              Function UpLoadFile(Const AOwner:TComponent;Const AFrameGuid,AOrderCode:String;Const ACapacitySpace:int64 = 30 * 1024 * 1024;Const UpLoadFileEvent:TUpLoadFileEvent = Nil):string;
              
              1

              說明: 通過檔案管理器上傳檔案 返回值: 無

              • FileUpload 函式語法中各部分說明
              部分 說明
              AOwner 所屬的主元件對像
              AFrameGuid 所屬的主ID對象,對應會在檔案上傳目錄下建立與ID同名的子資料夾
              AOrderCode 所屬的主ID下的子ID對象,對應會在檔案上傳目錄的主ID目錄下,建立與子ID同名的資料夾
              ACapacitySpace 設定目錄中允許上傳的最大檔案合計大小,以位元組為單位
              UpLoadFileEvent 當檔案上傳完成時需要觸發的事件名稱
              • 示例
                //JScript
                function UgButton01OnClick(sender)
                {
                  //通過與uploadfinished繫結,獲取上傳的檔名稱
                  UGMM.UpLoadFile(self,"ABC","12123",1000000,&uploadfinished);
                }
                
                function uploadfinished(aUpLoadList)
                {
                  showmessage(aUpLoadList);
                }
                
                1
                2
                3
                4
                5
                6
                7
                8
                9
                10
                11
                //PasScript
                procedure UgButton01OnClick(sender: TObject);
                begin
                  //通過與uploadfinished繫結,獲取上傳的檔名稱
                  UGMM.UpLoadFile(self,'ABC','12123',1000000,@uploadfinished);
                end;
                
                procedure uploadfinished(Const aUpLoadList:String);
                Begin
                  showmessage(aUpLoadList);
                end;
                
                1
                2
                3
                4
                5
                6
                7
                8
                9
                10
                11
                // Make sure to add code blocks to your code group

                # 1.8. GetObject

                Function  GetObject(Const ASign:String):TObject;
                
                1

                說明: 獲取執行緒管理共享對像 返回值: 對像類TObject

                • GetObject 函式語法中各部分說明
                部分 說明
                ASign 指定一個對像名稱Name
                • 示例
                  //JScript
                    var Obj;
                    obj = UGMM.GetObject("ObjectName");
                  
                  1
                  2
                  3
                  //PasScript
                  var
                   obj:TObject;
                  begin
                    obj := UGMM.GetObject('ObjectName');
                  End;
                  
                  1
                  2
                  3
                  4
                  5
                  6
                  // Make sure to add code blocks to your code group

                  # 1.9. GetWebSubForm

                  Function  GetWebSubForm(ACaption:String;Const AMenuFlag:String = '';Const AType:String = 'WEB'):TUniForm;
                  
                  1

                  說明: 獲取子窗體(Desktop) 返回值: 窗體類TUniForm

                  • GetWebSubForm 函式語法中各部分說明
                  部分 說明
                  ACaption 指定一個子窗體名稱,可使用模組編碼或者模組標題
                  AMenuFlag 功能表參數資訊,呼叫運行后,可在視窗模組的MenuFlag屬性中獲取數值
                  AType 指定子窗體型別(預設Web)
                  • 示例
                    //JScript
                      var F,i;
                      F = UGMM.GetWebSubForm("WebSubForm");
                      TUgWebForm(F).Caption = "SubForm"; 
                      ...
                      if (F.ShowModal == mrOK) 
                      {
                         TUgWebForm(F).Close;
                      }
                    
                    1
                    2
                    3
                    4
                    5
                    6
                    7
                    8
                    9
                    //PasScript
                    Var
                      F:TUniForm;
                      i:String;
                    begin
                      //打開任務登記
                      F := UGMM.GetWebSubForm('WebSubForm');
                      TUgWebForm(F).Caption := 'SubForm'; 
                      ...
                      if F.ShowModal = mrOK then 
                      Begin
                         TUgWebForm(F).Close;
                      End;
                    end;
                    
                    1
                    2
                    3
                    4
                    5
                    6
                    7
                    8
                    9
                    10
                    11
                    12
                    13
                    14
                    // Make sure to add code blocks to your code group

                    # 1.10. GetAppSubForm

                    Function  GetAppSubForm(ACaption:String;Const AMenuFlag:String = '';Const AFullScreen:Boolean = True):TUnimForm;
                    
                    1

                    說明: 獲取子窗體(Mobile) 返回值: 窗體類TUniForm

                    • GetAppSubForm 函式語法中各部分說明
                    部分 說明
                    ACaption 指定一個子窗體名稱,可使用模組編碼或者模組標題
                    AMenuFlag 功能表參數資訊,呼叫運行后,可在視窗模組的MenuFlag屬性中獲取數值
                    AFullScreen 指定是否全螢幕顯示
                    • 示例
                      //JScript
                        var F,i;
                        F = UGMM.GetAppSubForm("AppSubForm");
                        TUgAppForm(F).Caption = "SubForm"; 
                        ...
                        if (F.ShowModal == mrOK) 
                        {
                           TUgAppForm(F).Close;
                        }
                      
                      1
                      2
                      3
                      4
                      5
                      6
                      7
                      8
                      9
                      //PasScript
                      Var
                        F:TUnimForm;
                        i:String;
                      begin
                        //打開任務登記
                        F := UGMM.GetAppSubForm('AppSubForm');
                        TUgAppForm(F).Caption := 'SubForm'; 
                        ...
                        if F.ShowModal = mrOK then 
                        Begin
                           TUgAppForm(F).Close;
                        End;
                      end;
                      
                      1
                      2
                      3
                      4
                      5
                      6
                      7
                      8
                      9
                      10
                      11
                      12
                      13
                      14
                      // Make sure to add code blocks to your code group

                      # 1.11. GetBeanCaption

                      function  GetBeanCaption(AGuid:String):string;
                      
                      1

                      說明:通過Bean模組ID來獲取Bean模組的標題描述名稱。 返回值: string

                      • GetBeanCaption 函式語法中各部分說明
                      部分 說明
                      AGuid 指定一個子窗體ID

                      # 1.12. GetBeanCode

                      function  GetBeanCode(AGuid:String):string;
                      
                      1

                      說明: 通過Bean模組ID來獲取Bean模組的編號 返回值: string

                      • GetBeanCode 函式語法中各部分說明
                      部分 說明
                      AGuid 指定一個子窗體ID
                      • 示例
                        //JScript
                        UGMM.GetBeanCode("8F62424E-FD72-422B-8C2F-0A25A4F9FEAC");
                        
                        1
                        2
                        //PasScript
                        UGMM.GetBeanCode('8F62424E-FD72-422B-8C2F-0A25A4F9FEAC');
                        
                        1
                        2
                        // Make sure to add code blocks to your code group

                        # 1.13. GetBeanToSql

                        function  GetBeanToSql(Const AGuid:String):string;
                        
                        1

                        說明:將目前的Bean模組輸出為SQL指令碼,用於匯入至其他專案使用。 返回值String

                        • GetBeanToSql 函式語法說明
                        部分 說明
                        AGuid 指定一個子窗體ID

                        # 1.14. GetNodeDataLink

                        Function GetNodeDataLink(Const ANodeName:String):TFDConnection;
                        
                        1

                        說明: 獲取節點資料庫 返回值: TFDConnection

                        • GetNodeDataLink 函式語法中各部分說明
                        部分 說明
                        ACaption 指定一個子窗體名稱
                        AFullScreen 指定是否全螢幕顯示
                        • 示例
                          //JScript
                            var FDConn;
                            FDConn = UGMM.GetNodeDataLink("FastERP");
                            UgFDQuery01 := TUgFDQuery01.Create;
                            UgFDQuery01.Connection := FDConn;
                            try{
                               //打開數據
                              UgFDQuery01.SQL.Text := "Select * from Basic_Unit";
                              UgFDQuery01.Open();
                            }
                            Finally{
                              UgFDQuery01.free;
                            }
                          
                          1
                          2
                          3
                          4
                          5
                          6
                          7
                          8
                          9
                          10
                          11
                          12
                          13
                          //PasScript
                          Var  
                            FDConn:TFDConnection;
                          begin
                            //獲取 FastERP 節點資料庫
                            FDConn := UGMM.GetNodeDataLink('FastERP');
                            UgFDQuery01 := TUgFDQuery01.Create;
                            UgFDQuery01.Connection := FDConn;
                            try
                               //打開數據
                              UgFDQuery01.SQL.Text := 'Select * from Basic_Unit';
                              UgFDQuery01.Open();
                            Finally
                              UgFDQuery01.free;
                            end;
                          end;
                          
                          1
                          2
                          3
                          4
                          5
                          6
                          7
                          8
                          9
                          10
                          11
                          12
                          13
                          14
                          15
                          16
                          // Make sure to add code blocks to your code group

                          ---1.14.

                          # 1.15. GetRunFrame

                          Function  GetRunFrame(AOwner:TComponent;AKey:String;AGetSoure:TGetSource):TComponent;
                          
                          1

                          說明: 獲取運行模組 返回值: TComponent型別

                          • GetRunFrame 函式語法中各部分說明
                          部分 說明
                          AOwner 批定窗體所屬者
                          AKey 指定窗體的唯一Guid
                          AGetSoure 批定窗體來源型別(gsData,gsFile)
                          • 示例
                            //JScript
                              var M,R,C;
                              C = UGMM.GetRunFrame(Self,H,iif(pos(".",H) > 0,gsFile,gsData));
                              if (C != nil)
                              {
                                TControl(C).Parent = Self;
                                C.Name="WebHomePages";
                                TUGWebRunFrame(C).Align = TAlign.alClient;
                                if (C.GetInterface(IUGRunScript,R))
                                R.Run(nil);
                              }
                            
                            1
                            2
                            3
                            4
                            5
                            6
                            7
                            8
                            9
                            10
                            11
                            //PasScript
                            var
                              M : TMemoryStream;
                              R : IUGRunScript;
                              C : TComponent;
                            begin
                              C := UGMM.GetRunFrame(Self,H,iif(pos('.',H) > 0,gsFile,gsData));
                              if C <> nil then
                              begin
                                TControl(C).Parent := Self;
                                C.Name:='WebHomePages';
                                TUGWebRunFrame(C).Align := TAlign.alClient;
                                if C.GetInterface(IUGRunScript,R) Then
                                R.Run(nil);
                              end;
                            end;
                            
                            1
                            2
                            3
                            4
                            5
                            6
                            7
                            8
                            9
                            10
                            11
                            12
                            13
                            14
                            15
                            16
                            // Make sure to add code blocks to your code group

                            # 1.16. GetDesignFrame

                            Function  GetDesignFrame(AOwner:TComponent;AGuid:String):TComponent;
                            
                            1

                            說明: 獲取模組設計器 返回值: TComponent型別

                            • GetDesignFrame 函式語法中各部分說明
                            部分 說明
                            AOwner 批定窗體所屬者
                            AGuid 指定窗體的唯一Guid
                            • 示例
                              //JScript
                                var p,f,g;
                                if (cdsFrames.IsEmpty)
                                  RaiseException(UGMM.LT("Can't design without record"));
                                if (UGMM.Informations.Values["UserGuid"] != cdsFrames.FieldbyName("Developer").asString)
                                  RaiseException(UGMM.LT("You do not have permission to design this module")); 
                                if (Self.IsDesignMode)
                                  RaiseException(UGMM.LT("The module list is in IDE development mode. Design modules are prohibited"));
                              
                                g = cdsFrames.FieldbyName("Guid").AsString;
                                p = TUniTabSheet(Self.Parent.Owner.FindComponent("PDesign" + ReplaceText(ReplaceText(g,"-","_"),".","_")));
                                if (!Assigned(p))
                                {
                                  p = TUniTabSheet(Self.Parent.Owner);
                                  p.Name = "PDesign" + ReplaceText(ReplaceText(g,"-","_"),".","_");
                                  p.Caption =cdsFrames.FieldbyName("Caption").AsString + ".Web";
                                  p.PageControl = TUniTabSheet(Self.Parent).PageControl;
                                  p.Closable = True;
                              
                                  f = TUGDesignFrame(UGMM.GetDesignFrame(p,g));
                                  f.Align = alClient;
                                  f.Parent = p;
                                }
                                p.PageControl.ActivePage = p;
                              
                              1
                              2
                              3
                              4
                              5
                              6
                              7
                              8
                              9
                              10
                              11
                              12
                              13
                              14
                              15
                              16
                              17
                              18
                              19
                              20
                              21
                              22
                              23
                              24
                              //PasScript
                              Var
                                p:TUniTabSheet;
                                f:TUGDesignFrame;
                                g:String;
                              Begin
                                if cdsFrames.IsEmpty then
                                  RaiseException(UGMM.LT('Can''t design without record'));
                                if UGMM.Informations.Values['UserGuid'] <> cdsFrames.FieldbyName('Developer').asString then
                                  RaiseException(UGMM.LT('You do not have permission to design this module')); 
                                if Self.IsDesignMode then 
                                  RaiseException(UGMM.LT('The module list is in IDE development mode. Design modules are prohibited'));
                              
                                g := cdsFrames.FieldbyName('Guid').AsString;
                                p := TUniTabSheet(Self.Parent.Owner.FindComponent('PDesign' + ReplaceText(ReplaceText(g,'-','_'),'.','_')));
                                //showmessage(Self.Parent.Owner.name);
                                if Not Assigned(p) then
                                Begin
                                  p := TUniTabSheet.Create(Self.Parent.Owner);
                                  p.Name := 'PDesign' + ReplaceText(ReplaceText(g,'-','_'),'.','_');
                                  p.Caption :=cdsFrames.FieldbyName('Caption').AsString + '.Web';
                                  p.PageControl := TUniTabSheet(Self.Parent).PageControl;
                                  p.Closable := True;
                              
                                  f := TUGDesignFrame(UGMM.GetDesignFrame(p,g));
                                  f.Align := alClient;
                                  f.Parent := p;
                                End;
                                p.PageControl.ActivePage := p;
                              End;
                              
                              1
                              2
                              3
                              4
                              5
                              6
                              7
                              8
                              9
                              10
                              11
                              12
                              13
                              14
                              15
                              16
                              17
                              18
                              19
                              20
                              21
                              22
                              23
                              24
                              25
                              26
                              27
                              28
                              29
                              30
                              // Make sure to add code blocks to your code group

                              # 1.17. GetDesignFormatEditing

                              Function  GetDesignFormatEditing(AGuid:String):TComponent;
                              
                              1

                              說明: 獲取模組編輯器 返回值: TComponent型別

                              • GetDesignFormatEditing 函式語法中各部分說明
                              部分 說明
                              AGuid 指定窗體的唯一Guid
                              • 示例
                                //JScript
                                  var f,g;
                                  if (cdsFrames.IsEmpty)
                                    RaiseException(UGMM.LT("Can't design without record"));
                                  if (UGMM.Informations.Values["UserGuid"] != cdsFrames.FieldbyName("Developer").asString)
                                    RaiseException(UGMM.LT("You do not have permission to design this module")); 
                                  if (Self.IsDesignMode)
                                    RaiseException(UGMM.LT("The module list is in IDE development mode. Design modules are prohibited"));
                                  g = cdsFrames.FieldbyName("Guid").AsString;
                                  f = TUniForm(UGMM.GetDesignFormatEditing(g));
                                  f.ShowModal;
                                
                                1
                                2
                                3
                                4
                                5
                                6
                                7
                                8
                                9
                                10
                                11
                                //PasScript
                                Var
                                  f:TUniForm;
                                  g:String;
                                Begin
                                  if cdsFrames.IsEmpty then
                                    RaiseException(UGMM.LT('Can''t design without record'));
                                  if UGMM.Informations.Values['UserGuid'] <> cdsFrames.FieldbyName('Developer').asString then
                                    RaiseException(UGMM.LT('You do not have permission to design this module')); 
                                  if Self.IsDesignMode then 
                                    RaiseException(UGMM.LT('The module list is in IDE development mode. Design modules are prohibited'));
                                  g := cdsFrames.FieldbyName('Guid').AsString;
                                  f := TUniForm(UGMM.GetDesignFormatEditing(g));
                                  f.ShowModal;
                                End;
                                
                                1
                                2
                                3
                                4
                                5
                                6
                                7
                                8
                                9
                                10
                                11
                                12
                                13
                                14
                                15
                                // Make sure to add code blocks to your code group

                                # 1.18. GetDesignRestAPI

                                    Function  GetDesignRestAPI(AOwner:TComponent;AGuid:String):TComponent;
                                
                                1

                                說明: 獲取RestAPI介面編輯器 返回值: TComponent型別

                                • GetDesignRestAPI 函式語法中各部分說明
                                部分 說明
                                AOwner 批定窗體所屬者
                                AGuid 指定RestAPI介面的唯一Guid
                                • 示例
                                  //JScript
                                    var p,f,g;
                                    if (cdsFrames.IsEmpty)
                                      RaiseException(UGMM.LT("Can't design without record"));
                                    if (UGMM.Informations.Values["UserGuid"] != cdsFrames.FieldbyName("Developer").asString)
                                      RaiseException(UGMM.LT("You do not have permission to design this module")); 
                                    if (Self.IsDesignMode)
                                      RaiseException(UGMM.LT("The module list is in IDE development mode. Design modules are prohibited"));
                                  
                                    g = cdsFrames.FieldbyName("Guid").AsString;
                                    p = TUniTabSheet(Self.Parent.Owner.FindComponent("PDesign" + ReplaceText(ReplaceText(g,"-","_"),".","_")));
                                    if (!Assigned(p))
                                    {
                                      p = TUniTabSheet(Self.Parent.Owner);
                                      p.Name = "PDesign" + ReplaceText(ReplaceText(g,"-","_"),".","_");
                                      p.Caption =cdsFrames.FieldbyName("Caption").AsString + ".Web";
                                      p.PageControl = TUniTabSheet(Self.Parent).PageControl;
                                      p.Closable = True;
                                  
                                      f = TUGDesignFrame(UGMM.GetDesignFrame(p,g));
                                      f.Align = alClient;
                                      f.Parent = p;
                                    }
                                    p.PageControl.ActivePage = p;
                                  
                                  1
                                  2
                                  3
                                  4
                                  5
                                  6
                                  7
                                  8
                                  9
                                  10
                                  11
                                  12
                                  13
                                  14
                                  15
                                  16
                                  17
                                  18
                                  19
                                  20
                                  21
                                  22
                                  23
                                  24
                                  //PasScript
                                  Var
                                    g:String;
                                    f:TUniFrame;
                                    p:TUniTabSheet;
                                  begin
                                    if cdsRestAPIs.IsEmpty then
                                      RaiseException(UGMM.LT('Can''t design without record'));
                                    if UGMM.Informations.Values['UserGuid'] <> cdsRestAPIs.FieldbyName('Developer').asString then
                                      RaiseException(UGMM.LT('You do not have permission to design this module')); 
                                    if Self.IsDesignMode then 
                                      RaiseException(UGMM.LT('The module list is in IDE development mode. Design modules are prohibited'));
                                  
                                    g := cdsRestAPIs.FieldbyName('Guid').AsString;
                                  
                                    p := TUniTabSheet(Self.Parent.Owner.FindComponent('PDesign' + ReplaceText(ReplaceText(g,'-','_'),'.','_')));
                                  
                                    if Not Assigned(p) then
                                    Begin
                                      p := TUniTabSheet.Create(Self.Parent.Owner);
                                      p.Name := 'PDesign' + ReplaceText(ReplaceText(g,'-','_'),'.','_');
                                      p.Caption :=cdsRestAPIs.FieldbyName('APIName').AsString + '.Pas';
                                      p.PageControl := TUniTabSheet(Self.Parent).PageControl;
                                      p.Closable := True;
                                  
                                      f := TUniFrame(UGMM.GetDesignRestAPI(p,g));
                                      f.Align := alClient;
                                      f.Parent := p;
                                    End;
                                    p.PageControl.ActivePage := p;
                                  end;
                                  
                                  1
                                  2
                                  3
                                  4
                                  5
                                  6
                                  7
                                  8
                                  9
                                  10
                                  11
                                  12
                                  13
                                  14
                                  15
                                  16
                                  17
                                  18
                                  19
                                  20
                                  21
                                  22
                                  23
                                  24
                                  25
                                  26
                                  27
                                  28
                                  29
                                  30
                                  31
                                  // Make sure to add code blocks to your code group

                                  # 1.19. GetFrameCaption

                                  function  GetFrameCaption(AGuid:String):string;
                                  
                                  1

                                  說明: 根據模組地址獲取模組標題 返回值: string型別

                                  • GetFrameCaption 函式語法中各部分說明
                                  部分 說明
                                  AGuid 指定模組的唯一地址Guid
                                  • 示例
                                    //JScript
                                      var vCaption;
                                      vCaption = UGMM.GetFrameCaption("29B1B867-2CC6-413C-9058-FB332D3D0EDD");
                                    
                                    1
                                    2
                                    3
                                    //PasScript
                                    var
                                     vCaption:String;
                                    begin
                                      //獲取模組標題
                                      vCaption := UGMM.GetFrameCaption('29B1B867-2CC6-413C-9058-FB332D3D0EDD');
                                    end;
                                    
                                    1
                                    2
                                    3
                                    4
                                    5
                                    6
                                    7
                                    // Make sure to add code blocks to your code group

                                    # 1.20. GetLanguageByGrid

                                    function  GetLanguageByGrid(ALanuageName:String):string;
                                    
                                    1

                                    說明: 根據語言名稱查詢語言地址 返回值: string型別

                                    • GetLanguageByGrid 函式語法中各部分說明
                                    部分 說明
                                    ALanuageName 指定語言名稱

                                    # 1.21. GetLanguageByName

                                    function  GetLanguageByName(ALanuageGuid:String):string;
                                    
                                    1

                                    說明: 根據語言地址查詢語言名稱 返回值: string型別

                                    • GetLanguageByName 函式語法中各部分說明
                                    部分 說明
                                    ALanuageGuid 指定語言址址Guid

                                    # 1.22. GetUnitCode

                                    function  GetUnitCode(Const AGuid:String;Const AUnitName:string = ''):string;
                                    
                                    1

                                    說明: 獲取公共單元程式碼 返回值: string型別

                                    • GetUnitCode 函式語法中各部分說明
                                    部分 說明
                                    AGuid 指定模組唯一地址Guid
                                    AUnitName 指定模組單元名稱(可選)

                                    # 1.23. GetNavigRoleGuid

                                    Function  GetNavigRoleGuid(ANavig:Integer;ACreateTime:TDateTime):String;
                                    
                                    1

                                    說明: 獲取導航角色儲存地址 返回值: string型別

                                    • GetNavigRoleGuid 函式語法中各部分說明
                                    部分 說明
                                    ANavig 指定排序順序(tyFirst = 1;tyPrior = 2;tyNext = 3;tyLast = 4;)
                                    ACreateTime 指定排序時間

                                    # 1.24. GetNavigUserGuid

                                    Function  GetNavigUserGuid(ANavig:Integer;ACreateTime:TDateTime):String;
                                    
                                    1

                                    說明: 獲取導航使用者儲存地址 返回值: string型別

                                    • GetNavigUserGuid 函式語法中各部分說明
                                    部分 說明
                                    ANavig 指定排序順序(tyFirst = 1;tyPrior = 2;tyNext = 3;tyLast = 4;)
                                    ACreateTime 指定排序時間
                                    
                                    
                                    1

                                    # 1.25. GetNavigUserGuid

                                    Function  GetNavigUserGuid(ANavig:Integer;ACreateTime:TDateTime):String;
                                    
                                    1

                                    說明: 獲取導航使用者儲存地址 返回值: string型別

                                    • GetNavigUserGuid 函式語法中各部分說明
                                    部分 說明
                                    ANavig 指定排序順序(tyFirst = 1;tyPrior = 2;tyNext = 3;tyLast = 4;)
                                    ACreateTime 指定排序時間
                                    
                                    
                                    1

                                    # 1.26. GetDllComponent

                                    Function  GetDllComponent(APathName:String;AOwner:TComponent):TComponent;
                                    
                                    1

                                    說明: 獲取DLL中的窗體對像 返回值: TComponent型別

                                    • GetDllComponent 函式語法中各部分說明
                                    部分 說明
                                    APathName 指定窗體路徑
                                    AOwner 指定窗體的所有者Owner
                                    
                                    
                                    1

                                    # 1.27. GetSessionList

                                    Function  GetSessionList:TClientDataSet;
                                    
                                    1

                                    說明: 獲取會話列表 返回值: TComponent型別

                                    • GetSessionList 函式語法中各部分說明 無
                                    
                                    
                                    1

                                    # 1.28. GetSQLCommand

                                    function  GetSQLCommand(Const ASQLCommandId:String):TSQLCommand;
                                    
                                    1

                                    說明:返回SQLCommand對象。 返回值:TSQLCommand對象。

                                    • GetSQLCommand 函式語法中各部分說明
                                    部分 說明
                                    ASQLCommandId 預設SQL的編號

                                    # 1.29. GetSQLCommandNodeName

                                    function  GetSQLCommandNodeName(ASQLCommandId:String):string;
                                    
                                    1

                                    說明:返回預設SQL對應的節點資料庫名稱。 返回值:String型別。

                                    • GetSQLCommandNodeName 函式語法中各部分說明
                                    部分 說明
                                    ASQLCommandId 預設SQL的編號
                                      //JScript
                                      Strings = UGMM.GetSQLCommandNodeName("SQL001");
                                      
                                      1
                                      2
                                      //PasScript
                                      Strings := UGMM.GetSQLCommandNodeName('SQL001');
                                      
                                      1
                                      2
                                      // Make sure to add code blocks to your code group

                                      # 1.30. GetSQLCommandText

                                      function  GetSQLCommandText(Const ASQLCommandId:String):String;
                                      
                                      1

                                      說明:返回預設SQL文字的內容。 返回值:String型別。

                                      • GetSQLCommand 函式語法中各部分說明
                                      部分 說明
                                      ASQLCommandId 預設SQL的編號
                                        //JScript
                                        Strings = UGMM.GetSQLCommandText("SQL001");
                                        
                                        1
                                        2
                                        //PasScript
                                        Strings := UGMM.GetSQLCommandText('SQL001');
                                        
                                        1
                                        2
                                        // Make sure to add code blocks to your code group

                                        # 1.31. GetWebSubForm

                                        Function GetWebSubForm(AModuleName:String): TUgWebForm;
                                        
                                        1

                                        說明:根據指定的模組編號打開模組,顯示在視窗中。 返回值:TUgWebForm 型別。

                                        • GetWebSubForm 函式語法中各部分說明
                                        部分 說明
                                        AModuleName 要打開的模組的編號或模組的名稱
                                          //JScript
                                            var F;
                                            //打開布種資料編輯界面	W-EQ-MOD-2120-2
                                            F = UGMM.GetWebSubForm("W-EQ-MOD-2120-2");
                                            if (F.ShowModal == mrOK)
                                            {
                                          
                                            }
                                            //釋放打開的視窗W-EQ-MOD-2120-2
                                            UGMM.DelWebSubForm("W-EQ-MOD-2120-2");
                                          
                                          1
                                          2
                                          3
                                          4
                                          5
                                          6
                                          7
                                          8
                                          9
                                          10
                                          //PasScript
                                          var
                                            F: TUgWebForm;
                                          begin
                                            F := UGMM.GetWebSubForm('W-EQ-MOD-2120-2');
                                            if F.ShowModal = mrOK then
                                            begin
                                            
                                            end;
                                            //釋放打開的視窗W-EQ-MOD-2120-2
                                            UGMM.DelWebSubForm('W-EQ-MOD-2120-2');
                                          end;
                                          
                                          
                                          1
                                          2
                                          3
                                          4
                                          5
                                          6
                                          7
                                          8
                                          9
                                          10
                                          11
                                          12
                                          13
                                          // Make sure to add code blocks to your code group

                                          # 1.32. HTTPDecode

                                          function HTTPDecode(const AStr: string): string;
                                          
                                          1

                                          說明: HTTP解碼 返回值: 字元型別String

                                          • HTTPDecode 函式語法中各部分說明
                                          部分 說明
                                          AStr 指定需要解碼的字串

                                          # 1.33. HTTPEncode

                                          function HTTPEncode(const AStr: string): string;
                                          
                                          1

                                          說明: HTTP編碼 返回值: 字元型別String

                                          • HTTPEncode 函式語法中各部分說明
                                          部分 說明
                                          AStr 指定需要編碼的字串

                                          # 1.34. ImpExcel

                                          function ImpExcel(ADBGrid:TUgDBGrid;Const ACaption,ARequiredItems:String):Boolean;
                                          
                                          1

                                          說明: 從Excel表格中選擇數據匯入至數據表中。 返回值: 布爾型別: Boolean。

                                          • ImpExcel函式語法中各部分說明
                                          部分 說明
                                          ADBGrid 要接受數據的數據表格控制元件名稱
                                          ACaption 打開的匯入視窗的標題名稱
                                          ARequiredItems 設定所需項的名稱,可留空后在打開視窗中進行設定
                                          • 示例

                                            我們可以為其分配一個按鈕,一個數據表格控制元件以觸發事件:

                                            //JScript
                                            function UgButton05OnClick(sender){
                                                if (UGMM.ImpExcel(UgDBGrid01,"Import Excel",""))
                                                {
                                                  UgRFDataSet01.ApplyUpdates(-1);
                                                }
                                            }
                                            
                                            {
                                              UgRFDataSet01.Connection = GETRFWeb;
                                              UgRFDataSet01.SQL.Text = "SELECT TOP 0 * FROM Pass_Cust";
                                              UgRFDataSet01.Open;
                                            }
                                            
                                            1
                                            2
                                            3
                                            4
                                            5
                                            6
                                            7
                                            8
                                            9
                                            10
                                            11
                                            12
                                            13
                                            //PasScript
                                            procedure UgButton05OnClick(sender: tobject);
                                            begin
                                                if UGMM.ImpExcel(UgDBGrid01,'Import Excel','') then
                                                begin
                                                  UgRFDataSet01.ApplyUpdates(-1);
                                                End;
                                            end;
                                            
                                            Begin
                                              UgRFDataSet01.Connection := GETRFWeb;
                                              UgRFDataSet01.SQL.Text := 'SELECT TOP 0 * FROM Pass_Cust';
                                              UgRFDataSet01.Open;
                                            End.
                                            
                                            1
                                            2
                                            3
                                            4
                                            5
                                            6
                                            7
                                            8
                                            9
                                            10
                                            11
                                            12
                                            13
                                            14
                                            // Make sure to add code blocks to your code group

                                              運行後會打開界面,首先需要選擇Excel檔案上傳。請注意,這種方式對上傳的表格表頭有要求,表格的第一行必須是列的名稱。且表格中的其餘空白行不能有修改屬性等的操作。

                                              點選[Browse...]選擇檔案並點選[Upload]上傳,右側的表中雙擊各個行的Excel列名,在下拉表格中選擇表格中對應的列名。

                                              選擇完成後,點選右側的[匯入]按鈕,開始執行匯入操作。進度條達到100%后自動關閉對話方塊返回至原先的界面。


                                            # 1.35. LT

                                            Function  LT(AText:String):string;
                                            
                                            1

                                            說明: 獲取言語資訊 返回值: 字元型別String

                                            • LT 函式語法中各部分說明
                                            部分 說明
                                            AText 指定多語言關鍵字(預設語言內容)
                                            • 示例
                                              //JScript
                                                UgLabel01.Cantion := UGMM.LT("Cust Name");
                                              
                                              1
                                              2
                                              //PasScript
                                              begin
                                                UgLabel01.Cantion := UGMM.LT('Cust Name');
                                              End;
                                              
                                              1
                                              2
                                              3
                                              4
                                              // Make sure to add code blocks to your code group

                                              # 1.36. LogInChecking

                                              Function LogInChecking(AUserType,AUserName,APassWord,ALenguage,AModeType:String):Boolean;
                                              
                                              1

                                              說明: 驗證使用者登錄 返回值: Boolean型別

                                              • LogInChecking 函式語法中各部分說明
                                              部分 說明
                                              AUserType 使用者型別(開發使用者、框架使用者、系統使用者)
                                              AUserName 登錄使用者名稱
                                              APassWord 登錄使用者密碼
                                              ALenguage 指定使用者登錄語言
                                              AModeType 指定登錄型別(Web,App)
                                              • 示例
                                                //JScript
                                                  //驗證使用者密碼
                                                  if UGMM.LogInChecking(GetSignInType(FSignInType),edUserName.Text,edPassWord.Text,edLanguage.Text,"WEB")
                                                  {//密碼正確時登陸
                                                   ...
                                                  }
                                                
                                                1
                                                2
                                                3
                                                4
                                                5
                                                6
                                                //PasScript
                                                begin
                                                  //驗證使用者密碼
                                                  if UGMM.LogInChecking(GetSignInType(FSignInType),edUserName.Text,edPassWord.Text,edLanguage.Text,'WEB') then
                                                  begin//密碼正確時登陸
                                                   ...
                                                  end;
                                                end;
                                                
                                                1
                                                2
                                                3
                                                4
                                                5
                                                6
                                                7
                                                8
                                                // Make sure to add code blocks to your code group

                                                # 1.37. SendWsMsg

                                                function SendWsMsg(const acusername, acname, accom, atag, acevent: string;acparams:TStringlist=nil): Boolean;
                                                
                                                1

                                                說明:向指定的使用者登錄的Bean視窗發送WebSocket資訊。 返回值:Boolean,用於反饋是否發送成功。

                                                • SendWsMsg 函式語法中各部分說明
                                                部分 說明
                                                acusername 登錄的使用者名稱稱
                                                acname 動作名稱,指定為 callback
                                                accom 呼叫的Bean模組的編號
                                                atag 繫結的控制元件的Tag編號
                                                acevent 呼叫的事件名稱
                                                acparams 參數資訊,以鍵值對的方式進行
                                                • 示例
                                                  //JScript
                                                    var l;
                                                    l = new TStringList();
                                                    l.Values["text"] = "Hello WebSocket Test";
                                                    if (UGMM.SendWsMsg("demo","callback","bean-001","updatememo","0",l)) 
                                                    { 
                                                      ShowMessage("Send Success!");  
                                                    }
                                                    l.Free;
                                                  
                                                  1
                                                  2
                                                  3
                                                  4
                                                  5
                                                  6
                                                  7
                                                  8
                                                  9
                                                  //PasScript
                                                  var 
                                                    l: TStringList;
                                                  begin
                                                    l := TStringList.Create();
                                                    l.Values['text'] := 'Hello WebSocket Test';
                                                    if (UGMM.SendWsMsg('demo','callback','bean-001','updatememo','0',l))  then
                                                    begin
                                                      ShowMessage('Send Success!');  
                                                    end;
                                                    l.Free;
                                                  end;
                                                  
                                                  1
                                                  2
                                                  3
                                                  4
                                                  5
                                                  6
                                                  7
                                                  8
                                                  9
                                                  10
                                                  11
                                                  12
                                                  // Make sure to add code blocks to your code group

                                                  # 1.38. SendWsMsgBySId

                                                  function SendWsMsgBySId(const sid, msg: string): Boolean;
                                                  
                                                  1

                                                  說明:向指定的會話ID的客戶端發送WebSocket資訊。 返回值:Boolean,用於反饋是否發送成功。

                                                  • SendWsMsgBySId 函式語法中各部分說明
                                                  部分 說明
                                                  sid 指定會話的名稱
                                                  msg 要發送的訊息內容
                                                  • 示例
                                                    //JScript
                                                      UGMM.SendWsMsgBySId("esp32_001","Off");
                                                    
                                                    1
                                                    2
                                                    //PasScript
                                                      UGMM.SendWsMsgBySId('esp32_001','Off');
                                                    
                                                    1
                                                    2
                                                    // Make sure to add code blocks to your code group

                                                    # 1.39. SendWsMsgByStr

                                                    function SendWsMsgByStr(const msg: string): Boolean;
                                                    
                                                    1

                                                    說明:向WS伺服器發送WebSocket資訊。 返回值:Boolean,用於反饋是否發送成功。

                                                    • SendWsMsgByStr 函式語法中各部分說明
                                                    部分 說明
                                                    msg 要發送的訊息內容,僅支援傳輸指定的json
                                                    • 示例
                                                      //JScript
                                                        msg = "{" +
                                                          "\"username\": \"demo\"," +              					 		//WebSocket訊息發送的目標使用者
                                                           "\"action\": \"callback\"," +            					 		//WebSocket訊息告知IsoBean執行的動作
                                                           "\"tag\": \"0\"," + 
                                                           "\"data\": {" +
                                                              "\"callbackcomponent\": \"wb-das-0001_dashboard-demo1\"," +   	//執行動作的目標元件名稱
                                                              "\"callbackeventname\": \"update\"," +  			//執行觸發OnAjaxEvent事件的 eventname(事件名稱)
                                                          	"\"callbackparams\": [" +             						 //傳輸的鍵值,可以有一對或者多對
                                                            	"{" +
                                                                  "\"paramname\": \"type\"," +
                                                              	"\"paramvalue\": \"header\"" +
                                                            	"}," +
                                                            	"{" +
                                                              	"\"paramname\": \"dataMonthOrder\"," +
                                                              	"\"paramvalue\": \"" + Q.FieldByName("dataMonthOrder").asString + "\"" +
                                                            	"}," +
                                                            	"{" +
                                                                  "\"paramname\": \"dataNewMember\"," +
                                                              	"\"paramvalue\": \"" + Q.FieldByName("dataNewMeber").asString + "\"" +
                                                            	"}," +
                                                            	"{" +
                                                              	"\"paramname\": \"dataOnceConsume\"," +
                                                              	"\"paramvalue\": \"" + Q.FieldByName("dataOnceConsume").asString + "\"" +
                                                            	"}" +
                                                          	"]" +
                                                           "}" +
                                                        "}";
                                                        UGMM.SendWsMsgByStr(msg);
                                                      
                                                      1
                                                      2
                                                      3
                                                      4
                                                      5
                                                      6
                                                      7
                                                      8
                                                      9
                                                      10
                                                      11
                                                      12
                                                      13
                                                      14
                                                      15
                                                      16
                                                      17
                                                      18
                                                      19
                                                      20
                                                      21
                                                      22
                                                      23
                                                      24
                                                      25
                                                      26
                                                      27
                                                      28
                                                      29
                                                      //PasScript
                                                        msg = '{' +
                                                          '"username": "demo",' +              					 		//WebSocket訊息發送的目標使用者
                                                          '"action": "callback",' +            					 		//WebSocket訊息告知IsoBean執行的動作
                                                          '"tag": "0",' + 
                                                          '"data": {' +
                                                              '"callbackcomponent": "wb-das-0001_dashboard-demo1",' +   	//執行動作的目標元件名稱
                                                              '"callbackeventname": "update",' +  			//執行觸發OnAjaxEvent事件的 eventname(事件名稱)
                                                          	'"callbackparams": [' +             						 //傳輸的鍵值,可以有一對或者多對
                                                            	'{' +
                                                                  '"paramname": "type",' +
                                                              	'"paramvalue": "header"' +
                                                            	'},' +
                                                            	'{' +
                                                              	'"paramname": "dataMonthOrder",' +
                                                              	'"paramvalue": "' + Q.FieldByName('dataMonthOrder').asString + '"' +
                                                            	'},' +
                                                            	'{' +
                                                                  '"paramname": "dataNewMember",' +
                                                              	'"paramvalue": "' + Q.FieldByName('dataNewMeber').asString + '"' +
                                                            	'},' +
                                                            	'{' +
                                                              	'"paramname": "dataOnceConsume",' +
                                                              	'"paramvalue": "' + Q.FieldByName('dataOnceConsume').asString + '"' +
                                                            	'}' +
                                                          	']' +
                                                           '}' +
                                                        '}';
                                                        UGMM.SendWsMsgByStr(msg);
                                                      
                                                      1
                                                      2
                                                      3
                                                      4
                                                      5
                                                      6
                                                      7
                                                      8
                                                      9
                                                      10
                                                      11
                                                      12
                                                      13
                                                      14
                                                      15
                                                      16
                                                      17
                                                      18
                                                      19
                                                      20
                                                      21
                                                      22
                                                      23
                                                      24
                                                      25
                                                      26
                                                      27
                                                      28
                                                      29
                                                      // Make sure to add code blocks to your code group

                                                      # 1.40. URLDownloadToFile

                                                      Function URLDownloadToFile(AUrl: string;AFileName: string):Integer;
                                                      
                                                      1

                                                      說明: 根據URL下載檔案到指定目錄 返回值: Integer型別

                                                      • URLDownloadToFile 函式語法中各部分說明
                                                      部分 說明
                                                      AUrl 指定遠端檔案Url地址
                                                      AFileName 指定本地檔案路徑(含檔名)
                                                      • 示例
                                                        //JScript
                                                           //下載檔案到本地,並通過UgPDFFrame控制元件打開預覽
                                                           if (UGMM.URLDownloadToFile("File URL","temp\\report.pdf") == 0) 
                                                             UgPDFFrame01.PdfURL = "temp\\report.pdf";
                                                        
                                                        1
                                                        2
                                                        3
                                                        4
                                                        //PasScript
                                                           //下載檔案到本地,並通過UgPDFFrame控制元件打開預覽
                                                           if UGMM.URLDownloadToFile('File URL','temp\report.pdf') =0 then 
                                                             UgPDFFrame01.PdfURL := 'temp\report.pdf';
                                                        
                                                        1
                                                        2
                                                        3
                                                        4
                                                        // Make sure to add code blocks to your code group

                                                        # 1.41. VerifyRunFramePermType

                                                        Function  VerifyRunFramePermType(ARunFarme:TComponent;APermName:String;ACreateUser:String):Boolean;
                                                        
                                                        1

                                                        說明: 驗證運行模組型別許可權 返回值: Boolean型別

                                                        • VerifyRunFramePermType 函式語法中各部分說明
                                                        部分 說明
                                                        ARunFarme 指定窗體類
                                                        APermName 指定許可權名稱
                                                        ACreateUser 指定操作使用者
                                                        • 示例
                                                          //JScript
                                                             if (UGMM.VerifyRunFramePermType(TUgWebRunFrame(Self),"New","admin")
                                                             {
                                                               ShowMessage("permissions available");
                                                             }
                                                          
                                                          1
                                                          2
                                                          3
                                                          4
                                                          5
                                                          //PasScript
                                                          begin
                                                             if UGMM.VerifyRunFramePermType(TUgWebRunFrame(Self),'New','admin') Then
                                                             Begin
                                                               ShowMessage('permissions available');
                                                             end;
                                                          end;
                                                          
                                                          1
                                                          2
                                                          3
                                                          4
                                                          5
                                                          6
                                                          7
                                                          // Make sure to add code blocks to your code group

                                                          # 1.42. VerifyPermGuid

                                                          Function  VerifyPermGuid(AGuid:String):Boolean;
                                                          
                                                          1

                                                          說明: 以許可權地址獲取使用者是否有許可權 返回值: Boolean型別

                                                          • VerifyPermGuid 函式語法中各部分說明
                                                          部分 說明
                                                          AGuid 指定許可權唯一地址Guid
                                                          • 示例
                                                            //JScript
                                                               if (UGMM.VerifyPermGuid("Guid")
                                                               {
                                                                 ShowMessage("permissions available");
                                                               }
                                                            
                                                            1
                                                            2
                                                            3
                                                            4
                                                            5
                                                            //PasScript
                                                            begin
                                                               if UGMM.VerifyPermGuid('Guid') Then
                                                               Begin
                                                                 ShowMessage('permissions available');
                                                               end;
                                                            end;
                                                            
                                                            1
                                                            2
                                                            3
                                                            4
                                                            5
                                                            6
                                                            7
                                                            // Make sure to add code blocks to your code group

                                                            # 2. UGSM類函式

                                                              UGSM類程式在程式中呼叫時,必須以UGSM.開頭。


                                                            # 3. UGCM類函式

                                                              UGCM類程式在程式中呼叫時,必須以UGCM.開頭。

                                                            # 3.1. AmountToChinese

                                                            function AmountToChinese(ls: Variant): string;
                                                            
                                                            1

                                                            說明: 金額轉大寫(中文) 返回值: string型別

                                                            • AmountToChinese 函式語法中各部分說明
                                                            部分 說明
                                                            ls 指定一個金額(浮點數)
                                                            • 示例
                                                              //JScript
                                                                var Amount;
                                                                Amount = 123456.78;
                                                                Showmessage(UGCM.AmountToChinese(Amount));
                                                              
                                                              1
                                                              2
                                                              3
                                                              4
                                                              //PasScript
                                                              Var 
                                                                Amount:double;
                                                              begin
                                                                Amount := 123456.78;
                                                                Showmessage(UGCM.AmountToChinese(Amount));
                                                              end;
                                                              
                                                              1
                                                              2
                                                              3
                                                              4
                                                              5
                                                              6
                                                              7
                                                              // Make sure to add code blocks to your code group

                                                              運行結果 :壹拾貳萬叁仟肆佰伍拾陸元柒角捌分


                                                              # 3.2. GetFileStreamFileName

                                                              function GetFileStreamFileName(AFileStream: TFileStream): string;
                                                              
                                                              1

                                                              說明: 根據檔案流獲取檔名(含路徑) 返回值: string型別

                                                              • GetFileStreamFileName 函式語法中各部分說明
                                                              部分 說明
                                                              AFileStream 指定檔案流
                                                              • 示例
                                                                //JScript
                                                                function UgFileUploadButton01OnCompleted(sender,astream){
                                                                    var DestName,DestFolder;
                                                                    DestFolder=UGSM.StartPath+"temp\\";
                                                                    DestName=DestFolder+UgFileUploadButton01.FileName;
                                                                    //上傳檔案
                                                                    CopyFile(UGCM.GetFileStreamFileName(AStream), DestName, False);
                                                                    ugedit04.Text = DestName;
                                                                }
                                                                
                                                                1
                                                                2
                                                                3
                                                                4
                                                                5
                                                                6
                                                                7
                                                                8
                                                                9
                                                                //PasScript
                                                                procedure UgFileUploadButton01OnCompleted(sender: tobject;astream: tfilestream);
                                                                var
                                                                  DestName : string;
                                                                  DestFolder : string;
                                                                begin
                                                                    //遠端檔案路徑
                                                                    DestFolder:=UGSM.StartPath+'temp\';
                                                                    DestName:=DestFolder+UgFileUploadButton01.FileName;
                                                                    //上傳檔案
                                                                    CopyFile(UGCM.GetFileStreamFileName(AStream), DestName, False);
                                                                    ugedit04.Text := DestName;
                                                                end;
                                                                
                                                                1
                                                                2
                                                                3
                                                                4
                                                                5
                                                                6
                                                                7
                                                                8
                                                                9
                                                                10
                                                                11
                                                                12
                                                                13
                                                                // Make sure to add code blocks to your code group

                                                                # 3.3. Gettamptime

                                                                function Gettamptime(vtime: string; vlen: Integer): string;
                                                                
                                                                1

                                                                說明: 獲取時間戳 返回值: string型別

                                                                • Gettamptime 函式語法中各部分說明
                                                                部分 說明
                                                                vtime 指定一個時間
                                                                vlen 指定時間戳長度
                                                                • 示例
                                                                  //JScript
                                                                    var Time;
                                                                    Time = "2020-12-01 12:12:12";
                                                                    Showmessage(UGCM.Gettamptime(Time,13));
                                                                  
                                                                  1
                                                                  2
                                                                  3
                                                                  4
                                                                  //PasScript
                                                                  Var 
                                                                    Time:String;
                                                                  begin
                                                                    Time := '2020-12-01 12:12:12';
                                                                    Showmessage(UGCM.Gettamptime(Time,13));
                                                                  end;
                                                                  
                                                                  1
                                                                  2
                                                                  3
                                                                  4
                                                                  5
                                                                  6
                                                                  7
                                                                  // Make sure to add code blocks to your code group

                                                                  運行結果 :1606795932000


                                                                  # 3.4. GettampTotime

                                                                  function GettampTotime(vtamp: string): string; 
                                                                  
                                                                  1

                                                                  說明: 根據時間戳轉時間 返回值: string型別

                                                                  • GettampTotime 函式語法中各部分說明
                                                                  部分 說明
                                                                  vtamp 指定一個時間戳
                                                                  • 示例
                                                                    //JScript
                                                                      var Timetamp;
                                                                      Timetamp = "1606795932000";
                                                                      Showmessage(UGCM.GettampTotime(Timetamp));
                                                                    
                                                                    1
                                                                    2
                                                                    3
                                                                    4
                                                                    //PasScript
                                                                    Var 
                                                                      Timetamp:String;
                                                                    begin
                                                                      Timetamp := '1606795932000';
                                                                      Showmessage(UGCM.GettampTotime(Timetamp));
                                                                    end;
                                                                    
                                                                    1
                                                                    2
                                                                    3
                                                                    4
                                                                    5
                                                                    6
                                                                    7
                                                                    // Make sure to add code blocks to your code group

                                                                    運行結果 :2020-12-01 12:12:12.000


                                                                    # 3.5. HexStrToStream

                                                                    function HexStrToStream(AHexStr: string; AStream: TStream): Boolean;
                                                                    
                                                                    1

                                                                    說明: 16進位制轉流 返回值: Boolean型別

                                                                    • HexStrToStream 函式語法中各部分說明
                                                                    部分 說明
                                                                    AHexStr 指定16進位制字串
                                                                    AStream 指定流對像
                                                                    
                                                                    
                                                                    1

                                                                    # 3.6. HexToInt

                                                                    function HexToInt(const AHex: string): Integer;
                                                                    
                                                                    1

                                                                    說明: 16進位制轉整型 返回值: Integer型別

                                                                    • HexToInt 函式語法中各部分說明
                                                                    部分 說明
                                                                    AHex 指定16進位制字元
                                                                    • 示例
                                                                      //JScript
                                                                        var Hex;
                                                                        Hex = "0A";
                                                                        Showmessage(IntToStr(UGCM.HexToInt(Hex)));
                                                                      
                                                                      1
                                                                      2
                                                                      3
                                                                      4
                                                                      //PasScript
                                                                      Var 
                                                                        Hex:String;
                                                                      begin
                                                                        Hex := '0A';
                                                                        Showmessage(IntToStr(UGCM.HexToInt(Hex)));
                                                                      end;
                                                                      
                                                                      1
                                                                      2
                                                                      3
                                                                      4
                                                                      5
                                                                      6
                                                                      7
                                                                      // Make sure to add code blocks to your code group

                                                                      運行結果:10


                                                                      # 3.7. HexToBytes

                                                                      function HexToBytes(AHex: string): TBytes;
                                                                      
                                                                      1

                                                                      說明: 16進位制字串轉位元組陣列 返回值: TBytes型別

                                                                      • HexToBytes 函式語法中各部分說明
                                                                      部分 說明
                                                                      AHex 指定16進位制字串
                                                                      • 示例
                                                                      
                                                                      
                                                                      1

                                                                      # 3.8. RoundToCH

                                                                      function RoundToCH(const AValue: Double; const ADigit: Integer): Double;
                                                                      
                                                                      1

                                                                      說明: 四捨五入 返回值: Double型別

                                                                      • RoundToCH 函式語法中各部分說明
                                                                      部分 說明
                                                                      AValue 指定一個浮點數
                                                                      ADigit 指定小數位保留位數
                                                                      • 示例
                                                                        //JScript
                                                                        //保留一位小數
                                                                          var d;
                                                                          d=12345.56;
                                                                          Showmessage(FloatToStr(UGCM.RoundToCH(d,1)));
                                                                        
                                                                        1
                                                                        2
                                                                        3
                                                                        4
                                                                        5
                                                                        //PasScript
                                                                        //保留一位小數
                                                                        Var 
                                                                          d:double;
                                                                        begin
                                                                          d:=12345.56;
                                                                          Showmessage(FloatToStr(UGCM.RoundToCH(d,1)));
                                                                        end;
                                                                        
                                                                        1
                                                                        2
                                                                        3
                                                                        4
                                                                        5
                                                                        6
                                                                        7
                                                                        8
                                                                        // Make sure to add code blocks to your code group

                                                                        運行結果:12345.6


                                                                        # 3.9. NetHttpGet

                                                                         function NetHttpGet(const Qurl: string; const QSource:string = ''): string;
                                                                        
                                                                        1

                                                                        說明: HTTP GET方法,通過向請求地址發送GET 請求獲取返回資訊。 返回值: String型別,

                                                                        • NetHttpGet 函式語法中各部分說明
                                                                        部分 說明
                                                                        Qurl 指定一個地址
                                                                        QSource 請求體的內容,預設請保持為空狀態
                                                                        • 示例
                                                                          //JScript
                                                                          //ZoneMinder API用於獲取監視器列表
                                                                          //curl http://server/zm/api/monitors.json
                                                                            s = UGCM.NetHttpGet(edtURL.Text + "/monitors.json?token=" + token,"");
                                                                            mmLog.Lines.Clear;
                                                                            mmLog.Lines.Add(DateTimeToStr(now()) + ": " + s);
                                                                          
                                                                          1
                                                                          2
                                                                          3
                                                                          4
                                                                          5
                                                                          6
                                                                          //PasScript
                                                                          //ZoneMinder API用於獲取監視器列表
                                                                          //curl http://server/zm/api/monitors.json
                                                                          begin
                                                                            s := UGCM.NetHttpGet(edtURL.Text + '/monitors.json?token=' + token,'');
                                                                            mmLog.Lines.Clear;
                                                                            mmLog.Lines.Add(DateTimeToStr(now()) + ': ' + s);
                                                                          end;
                                                                          
                                                                          1
                                                                          2
                                                                          3
                                                                          4
                                                                          5
                                                                          6
                                                                          7
                                                                          8
                                                                          // Make sure to add code blocks to your code group

                                                                          # 3.10. NetHttpPost

                                                                          function NetHttpPost(const Qurl: string; const QSource: string = ''; const QResponseContent: string = ''; const QContentType: string = ''): string;
                                                                          
                                                                          1

                                                                          說明: HTTP POST方法,通過向請求地址發送POST請求獲取返回資訊。 返回值: String型別,

                                                                          • NetHttpPost 函式語法中各部分說明
                                                                          部分 說明
                                                                          Qurl 指定一個地址
                                                                          QSource 請求體的內容
                                                                          QResponseContent 請求響應的內容,預設保持為空的狀態
                                                                          QContentType 請求體聲明的內容型別,常用的有application/json、application/xml、application/x-www-form-urlencoded等
                                                                          • 示例
                                                                            //JScript
                                                                            //ZoneMinder 使用API來修改監視器功能
                                                                            //curl -XPOST http://server/zm/api/monitors/1.json -d "Monitor[Function]=Modect&Monitor[Enabled]=1"
                                                                              var postString,s;
                                                                              postString = "Monitor[Function]=" + cbFunction.Items.Strings[cbFunction.ItemIndex] + "&Monitor[Enabled]=1";
                                                                              s = UGCM.NetHttpPost(edtURL.Text + "/monitors/1.json?token=" + token,postString,"","application/x-www-form-urlencoded");
                                                                              mmLog.Lines.Clear;
                                                                              mmLog.Lines.Add(DateTimeToStr(now()) + ": " + s);
                                                                            
                                                                            1
                                                                            2
                                                                            3
                                                                            4
                                                                            5
                                                                            6
                                                                            7
                                                                            8
                                                                            //PasScript
                                                                            //ZoneMinder 使用API來修改監視器功能
                                                                            //curl -XPOST http://server/zm/api/monitors/1.json -d "Monitor[Function]=Modect&Monitor[Enabled]=1"
                                                                            Var
                                                                              s: string;
                                                                              postString: string;
                                                                            begin
                                                                                postString := 'Monitor[Function]=' + cbFunction.Items.Strings[cbFunction.ItemIndex] + '&Monitor[Enabled]=1';
                                                                                s := UGCM.NetHttpPost(edtURL.Text + '/monitors/1.json?token=' + token,postString,'','application/x-www-form-urlencoded');
                                                                                mmLog.Lines.Clear;
                                                                                mmLog.Lines.Add(DateTimeToStr(now()) + ': ' + s);
                                                                            end;
                                                                            
                                                                            1
                                                                            2
                                                                            3
                                                                            4
                                                                            5
                                                                            6
                                                                            7
                                                                            8
                                                                            9
                                                                            10
                                                                            11
                                                                            12
                                                                            // Make sure to add code blocks to your code group

                                                                            # 3.11. NetHttpPut

                                                                            function NetHttpPut(const Qurl: string; const QSource: string = ''; const QResponseContent: string = ''; const QContentType: string = ''): string;
                                                                            
                                                                            1

                                                                            說明: HTTP PUT方法,通過向請求地址發送PUT請求獲取返回資訊。 返回值: String型別。

                                                                            • NetHttpPut 函式語法中各部分說明
                                                                            部分 說明
                                                                            Qurl 指定一個地址
                                                                            QSource 請求體的內容
                                                                            QResponseContent 請求響應的內容,預設保持為空的狀態
                                                                            QContentType 請求體聲明的內容型別,常用的有application/json、application/xml、application/x-www-form-urlencoded等
                                                                            • 示例
                                                                              //JScript
                                                                              //ZoneMinder使用API來編輯監視器
                                                                              //此命令會將監視器 1 的「名稱」欄位更改為「test1」
                                                                              //curl -XPUT http://server/zm/api/monitors/1.json -d "Monitor[Name]=test1"
                                                                              //修改檢視器名稱
                                                                                var s;
                                                                                s = UGCM.NetHttpPut(edtURL.Text + "/monitors/1.json?token=" + token,"Monitor[Name]=" + 
                                                                                edtMonitorName.Text,"","application/x-www-form-urlencoded");
                                                                                mmLog.Lines.Clear;
                                                                                mmLog.Lines.Add(DateTimeToStr(now()) + ": " + s);
                                                                              
                                                                              1
                                                                              2
                                                                              3
                                                                              4
                                                                              5
                                                                              6
                                                                              7
                                                                              8
                                                                              9
                                                                              10
                                                                              //PasScript
                                                                              //ZoneMinder使用API來編輯監視器
                                                                              //此命令會將監視器 1 的「名稱」欄位更改為「test1」
                                                                              //curl -XPUT http://server/zm/api/monitors/1.json -d "Monitor[Name]=test1"
                                                                              //修改檢視器名稱
                                                                              Var
                                                                                s: string;
                                                                              begin
                                                                                s := UGCM.NetHttpPut(edtURL.Text + '/monitors/1.json?token=' + token,'Monitor[Name]=' + 
                                                                                edtMonitorName.Text,'','application/x-www-form-urlencoded');
                                                                                mmLog.Lines.Clear;
                                                                                mmLog.Lines.Add(DateTimeToStr(now()) + ': ' + s);
                                                                              end;
                                                                              
                                                                              1
                                                                              2
                                                                              3
                                                                              4
                                                                              5
                                                                              6
                                                                              7
                                                                              8
                                                                              9
                                                                              10
                                                                              11
                                                                              12
                                                                              13
                                                                              // Make sure to add code blocks to your code group

                                                                              # 3.12. NetHttpDelete

                                                                              function NetHttpDelete(const Qurl: string; const QSource:string = ''): string;
                                                                              
                                                                              1

                                                                              說明: HTTP DELETE方法,通過向請求地址發送DELETE請求獲取返回資訊。 返回值: String型別。

                                                                              • NetHttpDelete 函式語法中各部分說明
                                                                              部分 說明
                                                                              QUrl 指定一個地址
                                                                              QSource 請求體的內容,預設請保持為空狀態
                                                                              • 示例
                                                                                //JScript
                                                                                //ZoneMinder使用API來刪除監視器
                                                                                //curl -XDELETE http://server/zm/api/monitors/1.json
                                                                                //刪除監視器
                                                                                  var s;
                                                                                  s = UGCM.NetHttpDelete(edtURL.Text + "/monitors/4.json?token=" + token,"");
                                                                                  mmLog.Lines.Clear;
                                                                                  mmLog.Lines.Add(DateTimeToStr(now()) + ": " + s);
                                                                                
                                                                                1
                                                                                2
                                                                                3
                                                                                4
                                                                                5
                                                                                6
                                                                                7
                                                                                8
                                                                                //PasScript
                                                                                //ZoneMinder使用API來刪除監視器
                                                                                //curl -XDELETE http://server/zm/api/monitors/1.json
                                                                                //刪除監視器
                                                                                var
                                                                                  s: string;
                                                                                begin
                                                                                  s := UGCM.NetHttpDelete(edtURL.Text + '/monitors/4.json?token=' + token,'');
                                                                                  mmLog.Lines.Clear;
                                                                                  mmLog.Lines.Add(DateTimeToStr(now()) + ': ' + s);
                                                                                end;
                                                                                
                                                                                1
                                                                                2
                                                                                3
                                                                                4
                                                                                5
                                                                                6
                                                                                7
                                                                                8
                                                                                9
                                                                                10
                                                                                11
                                                                                // Make sure to add code blocks to your code group

                                                                                # 3.13. GetJSONObject

                                                                                function GetJSONObject(const QJSONObject: TJSONObject; const QPath:String):TJSONObject;
                                                                                
                                                                                1

                                                                                說明: 獲取JSON對像中指定的巢狀對象。 返回值: TJSONObject型別。

                                                                                • GetJSONObject 函式語法中各部分說明
                                                                                部分 說明
                                                                                QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌
                                                                                • 示例

                                                                                  假設需要對以下JSON進行解析。

                                                                                {
                                                                                    "status": "OK",
                                                                                    "Language":{
                                                                                        "DefaultLanguage": 1
                                                                                    }
                                                                                }
                                                                                
                                                                                1
                                                                                2
                                                                                3
                                                                                4
                                                                                5
                                                                                6
                                                                                  //JScript
                                                                                    var J,s;
                                                                                    J= new TJSONObject();
                                                                                    s= "{\"status\": \"OK\",\"Language\":{\"DefaultLanguage\": 1}}";
                                                                                    Try{
                                                                                       j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                       j =UGCM.GetJSONObject(j,"Language");
                                                                                       ShowMessage(UGCM.GetJSONNumber(j,"DefaultLanguage"));
                                                                                    }
                                                                                    Finally{
                                                                                      j.Free;
                                                                                    }
                                                                                  
                                                                                  1
                                                                                  2
                                                                                  3
                                                                                  4
                                                                                  5
                                                                                  6
                                                                                  7
                                                                                  8
                                                                                  9
                                                                                  10
                                                                                  11
                                                                                  12
                                                                                  //PasScript
                                                                                  Var 
                                                                                    J:TJSONObject;
                                                                                    s: String;
                                                                                  begin
                                                                                    J:=TJSONObject.Create;
                                                                                    s:= '{"status": "OK","Language":{"DefaultLanguage": 1}}';
                                                                                    Try
                                                                                       j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                       j :=UGCM.GetJSONObject(j,'Language');
                                                                                       ShowMessage(UGCM.GetJSONNumber(j,'DefaultLanguage'));
                                                                                       //上述兩句程式也可改寫為
                                                                                       //ShowMessage(UGCM.GetJSONNumber(j,'Language.DefaultLanguage'));
                                                                                    Finally
                                                                                      j.Free;
                                                                                    end;
                                                                                  end;
                                                                                  
                                                                                  1
                                                                                  2
                                                                                  3
                                                                                  4
                                                                                  5
                                                                                  6
                                                                                  7
                                                                                  8
                                                                                  9
                                                                                  10
                                                                                  11
                                                                                  12
                                                                                  13
                                                                                  14
                                                                                  15
                                                                                  16
                                                                                  17
                                                                                  // Make sure to add code blocks to your code group

                                                                                    以上程式運行后獲取到的值為1。

                                                                                  # 3.14. GetJSONArray

                                                                                  function GetJSONArray(const QJSONObject: TJSONObject; const QPath:String):TJSONArray;
                                                                                  
                                                                                  1

                                                                                  說明: 獲取JSON對像中指定的陣列列。 返回值: TJSONArray型別。

                                                                                  • GetJSONArray 函式語法中各部分說明
                                                                                  部分 說明
                                                                                  QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                  QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌
                                                                                  • 示例

                                                                                    假設需要對以下JSON進行解析。

                                                                                  {
                                                                                      "status": "OK",
                                                                                      "Language":{
                                                                                          "DefaultLanguage": 1,
                                                                                          "options":[
                                                                                              {"options":1},
                                                                                              {"options":2}
                                                                                          ]
                                                                                      }
                                                                                  }
                                                                                  
                                                                                  1
                                                                                  2
                                                                                  3
                                                                                  4
                                                                                  5
                                                                                  6
                                                                                  7
                                                                                  8
                                                                                  9
                                                                                  10
                                                                                    //JScript
                                                                                      var J,A,s;
                                                                                      J= new TJSONObject();
                                                                                      A= new TJSONArray();
                                                                                      s= "{\"status\": \"OK\",\"Language\":{\"DefaultLanguage\": 1,\"options\":[{\"options\":1},{\"options\":2}]}}";
                                                                                      Try{
                                                                                         j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                         A = UGCM.GetJSONArray(j,"Language.options");
                                                                                         J = TJSONObject(A.Items[1]);
                                                                                         ShowMessage(UGCM.GetJSONNumber(j,"options"));
                                                                                      }
                                                                                      Finally{
                                                                                        j.Free;
                                                                                        A.Free;
                                                                                      }
                                                                                    
                                                                                    1
                                                                                    2
                                                                                    3
                                                                                    4
                                                                                    5
                                                                                    6
                                                                                    7
                                                                                    8
                                                                                    9
                                                                                    10
                                                                                    11
                                                                                    12
                                                                                    13
                                                                                    14
                                                                                    15
                                                                                    //PasScript
                                                                                    Var 
                                                                                      J:TJSONObject;
                                                                                      A:TJSONArray;
                                                                                      s: String;
                                                                                    begin
                                                                                      J:=TJSONObject.Create;
                                                                                      A:= TJSONArray.Create;
                                                                                      s:= '{"status": "OK","Language":{"DefaultLanguage": 1,"options":[{"options":1},{"options":2}]}}';
                                                                                      Try
                                                                                         j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                         A := UGCM.GetJSONArray(j,'Language.options');
                                                                                         J := TJSONObject(A.Items[1]);
                                                                                         ShowMessage(UGCM.GetJSONNumber(j,'options'));
                                                                                      Finally
                                                                                        j.Free;
                                                                                        A.Free;
                                                                                      end;
                                                                                    end;
                                                                                    
                                                                                    1
                                                                                    2
                                                                                    3
                                                                                    4
                                                                                    5
                                                                                    6
                                                                                    7
                                                                                    8
                                                                                    9
                                                                                    10
                                                                                    11
                                                                                    12
                                                                                    13
                                                                                    14
                                                                                    15
                                                                                    16
                                                                                    17
                                                                                    18
                                                                                    19
                                                                                    // Make sure to add code blocks to your code group

                                                                                      以上程式運行后獲取到的值為2。

                                                                                    # 3.15. GetJSONString

                                                                                    function GetJSONString(const QJSONObject: TJSONObject; const QPath:String):String;
                                                                                    
                                                                                    1

                                                                                    說明: 獲取JSON對像中指定鍵值的字串。 返回值: String型別。

                                                                                    • GetJSONString 函式語法中各部分說明
                                                                                    部分 說明
                                                                                    QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                    QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌

                                                                                      假設需要對以下JSON進行解析。

                                                                                    {
                                                                                        "status": "OK",
                                                                                        "Language":{
                                                                                            "DefaultLanguage": 1
                                                                                        }
                                                                                    }
                                                                                    
                                                                                    1
                                                                                    2
                                                                                    3
                                                                                    4
                                                                                    5
                                                                                    6
                                                                                      //JScript
                                                                                        var J,s;
                                                                                        J= new TJSONObject();
                                                                                        s= "{\"status\": \"OK\",\"Language\":{\"DefaultLanguage\": 1}}";
                                                                                        Try{
                                                                                           j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                           ShowMessage(UGCM.GetJSONString(j,"status"));
                                                                                        }
                                                                                        Finally{
                                                                                          j.Free;
                                                                                        }
                                                                                      
                                                                                      1
                                                                                      2
                                                                                      3
                                                                                      4
                                                                                      5
                                                                                      6
                                                                                      7
                                                                                      8
                                                                                      9
                                                                                      10
                                                                                      11
                                                                                      //PasScript
                                                                                      Var 
                                                                                        J:TJSONObject;
                                                                                        s: String;
                                                                                      begin
                                                                                        J:=TJSONObject.Create;
                                                                                        s:= '{"status": "OK","Language":{"DefaultLanguage": 1}}';
                                                                                        Try
                                                                                           j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                           ShowMessage(UGCM.GetJSONString(j,'status'));
                                                                                        Finally
                                                                                          j.Free;
                                                                                        end;
                                                                                      end;
                                                                                      
                                                                                      1
                                                                                      2
                                                                                      3
                                                                                      4
                                                                                      5
                                                                                      6
                                                                                      7
                                                                                      8
                                                                                      9
                                                                                      10
                                                                                      11
                                                                                      12
                                                                                      13
                                                                                      14
                                                                                      // Make sure to add code blocks to your code group

                                                                                        以上程式運行后獲取到的值為OK。

                                                                                      # 3.16. GetJSONNumber

                                                                                      function GetJSONNumber(const QJSONObject: TJSONObject; const QPath:String):String;
                                                                                      
                                                                                      1

                                                                                      說明: 獲取JSON對像中指定的鍵值中的數值。 返回值: String型別。

                                                                                      • GetJSONNumber 函式語法中各部分說明
                                                                                      部分 說明
                                                                                      QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                      QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌
                                                                                      • 示例

                                                                                        假設需要對以下JSON進行解析。

                                                                                      {
                                                                                          "status": "OK",
                                                                                          "Language":{
                                                                                              "DefaultLanguage": 1
                                                                                          }
                                                                                      }
                                                                                      
                                                                                      1
                                                                                      2
                                                                                      3
                                                                                      4
                                                                                      5
                                                                                      6
                                                                                        //JScript
                                                                                          var J,s;
                                                                                          J= new TJSONObject();
                                                                                          s= "{\"status\": \"OK\",\"Language\":{\"DefaultLanguage\": 1}}";
                                                                                          Try{
                                                                                             j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                             j =UGCM.GetJSONObject(j,"Language");
                                                                                             ShowMessage(UGCM.GetJSONNumber(j,"DefaultLanguage"));
                                                                                          }
                                                                                          Finally{
                                                                                            j.Free;
                                                                                          }
                                                                                        
                                                                                        1
                                                                                        2
                                                                                        3
                                                                                        4
                                                                                        5
                                                                                        6
                                                                                        7
                                                                                        8
                                                                                        9
                                                                                        10
                                                                                        11
                                                                                        12
                                                                                        //PasScript
                                                                                        Var 
                                                                                          J:TJSONObject;
                                                                                          s: String;
                                                                                        begin
                                                                                          J:=TJSONObject.Create;
                                                                                          s:= '{"status": "OK","Language":{"DefaultLanguage": 1}}';
                                                                                          Try
                                                                                             j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                             j :=UGCM.GetJSONObject(j,'Language');
                                                                                             ShowMessage(UGCM.GetJSONNumber(j,'DefaultLanguage'));
                                                                                             //上述兩句程式也可改寫為
                                                                                             //ShowMessage(UGCM.GetJSONNumber(j,'Language.DefaultLanguage'));
                                                                                          Finally
                                                                                            j.Free;
                                                                                          end;
                                                                                        end;
                                                                                        
                                                                                        1
                                                                                        2
                                                                                        3
                                                                                        4
                                                                                        5
                                                                                        6
                                                                                        7
                                                                                        8
                                                                                        9
                                                                                        10
                                                                                        11
                                                                                        12
                                                                                        13
                                                                                        14
                                                                                        15
                                                                                        16
                                                                                        17
                                                                                        // Make sure to add code blocks to your code group

                                                                                          以上程式運行后獲取到的值為1。

                                                                                        # 3.17. GetJSONInteger

                                                                                        function GetJSONInteger(const QJSONObject: TJSONObject; const QPath:String):Integer;
                                                                                        
                                                                                        1

                                                                                        說明: 獲取JSON對像中指定的鍵值中的整數數值,並以整數的形式返回。 返回值: Integer型別。

                                                                                        • GetJSONInteger 函式語法中各部分說明
                                                                                        部分 說明
                                                                                        QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                        QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌
                                                                                        • 示例

                                                                                          假設需要對以下JSON進行解析。

                                                                                        {
                                                                                            "status": "OK",
                                                                                            "Language":{
                                                                                                "DefaultLanguage": 1
                                                                                            }
                                                                                        }
                                                                                        
                                                                                        1
                                                                                        2
                                                                                        3
                                                                                        4
                                                                                        5
                                                                                        6
                                                                                          //JScript
                                                                                            var J,s;
                                                                                            J= new TJSONObject();
                                                                                            s= "{\"status\": \"OK\",\"Language\":{\"DefaultLanguage\": 1}}";
                                                                                            Try{
                                                                                               j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                               i = UGCM.GetJSONInteger(j,"Language.DefaultLanguage");
                                                                                               ShowMessage(IntToStr(i));
                                                                                            }
                                                                                            Finally{
                                                                                              j.Free;
                                                                                            }
                                                                                          
                                                                                          1
                                                                                          2
                                                                                          3
                                                                                          4
                                                                                          5
                                                                                          6
                                                                                          7
                                                                                          8
                                                                                          9
                                                                                          10
                                                                                          11
                                                                                          12
                                                                                          //PasScript
                                                                                          Var 
                                                                                            J:TJSONObject;
                                                                                            s: String;
                                                                                            i: Integer;
                                                                                          begin
                                                                                            J:=TJSONObject.Create;
                                                                                            s:= '{"status": "OK","Language":{"DefaultLanguage": 1}}';
                                                                                            Try
                                                                                               j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                               i := UGCM.GetJSONInteger(j,'Language.DefaultLanguage');
                                                                                               ShowMessage(IntToStr(i));
                                                                                            Finally
                                                                                              j.Free;
                                                                                            end;
                                                                                          end;
                                                                                          
                                                                                          1
                                                                                          2
                                                                                          3
                                                                                          4
                                                                                          5
                                                                                          6
                                                                                          7
                                                                                          8
                                                                                          9
                                                                                          10
                                                                                          11
                                                                                          12
                                                                                          13
                                                                                          14
                                                                                          15
                                                                                          16
                                                                                          // Make sure to add code blocks to your code group

                                                                                            以上程式運行后獲取到的值為1。

                                                                                          # 3.18. GetJSONFloat

                                                                                          function GetJSONFloat(const QJSONObject: TJSONObject; const QPath:String):Double;
                                                                                          
                                                                                          1

                                                                                          說明: 獲取JSON對像中指定的鍵值中的浮點數數值,並以浮點數的形式返回。 返回值: Double型別。

                                                                                          • GetJSONFloat 函式語法中各部分說明
                                                                                          部分 說明
                                                                                          QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                          QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌
                                                                                          • 示例

                                                                                            假設需要對以下JSON進行解析。

                                                                                          {
                                                                                              "status": "OK",
                                                                                              "Language":{
                                                                                                  "DefaultLanguage": 1.1
                                                                                              }
                                                                                          }
                                                                                          
                                                                                          1
                                                                                          2
                                                                                          3
                                                                                          4
                                                                                          5
                                                                                          6
                                                                                            //JScript
                                                                                              var J,s;
                                                                                              J= new TJSONObject();
                                                                                              s= "{\"status\": \"OK\",\"Language\":{\"DefaultLanguage\": 1.1}}";
                                                                                              Try{
                                                                                                 j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                                 i = UGCM.GetJSONFloat(j,"Language.DefaultLanguage");
                                                                                                 ShowMessage(FloatToStr(i));
                                                                                              }
                                                                                              Finally{
                                                                                                j.Free;
                                                                                              }
                                                                                            
                                                                                            1
                                                                                            2
                                                                                            3
                                                                                            4
                                                                                            5
                                                                                            6
                                                                                            7
                                                                                            8
                                                                                            9
                                                                                            10
                                                                                            11
                                                                                            12
                                                                                            //PasScript
                                                                                            Var 
                                                                                              J:TJSONObject;
                                                                                              s: String;
                                                                                              i: Double;
                                                                                            begin
                                                                                              J:=TJSONObject.Create;
                                                                                              s:= '{"status": "OK","Language":{"DefaultLanguage": 1.1}}';
                                                                                              Try
                                                                                                 j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                                 i := UGCM.GetJSONFloat(j,'Language.DefaultLanguage');
                                                                                                 ShowMessage(FloatToStr(i));
                                                                                              Finally
                                                                                                j.Free;
                                                                                              end;
                                                                                            end;
                                                                                            
                                                                                            1
                                                                                            2
                                                                                            3
                                                                                            4
                                                                                            5
                                                                                            6
                                                                                            7
                                                                                            8
                                                                                            9
                                                                                            10
                                                                                            11
                                                                                            12
                                                                                            13
                                                                                            14
                                                                                            15
                                                                                            16
                                                                                            // Make sure to add code blocks to your code group

                                                                                              以上程式運行后獲取到的值為1.1。

                                                                                            # 3.19. GetJSONBool

                                                                                            function GetJSONBool(const QJSONObject: TJSONObject; const QPath:String):Boolean;
                                                                                            
                                                                                            1

                                                                                            說明: 獲取JSON對像中指定的鍵值中的布爾數值,並以布林值的形式返回。 返回值: Boolean型別。

                                                                                            • GetJSONBool 函式語法中各部分說明
                                                                                            部分 說明
                                                                                            QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                            QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌

                                                                                              假設需要對以下JSON進行解析。

                                                                                            {
                                                                                                "status": true,
                                                                                                "Language":{
                                                                                                    "DefaultLanguage": 1
                                                                                                }
                                                                                            }
                                                                                            
                                                                                            1
                                                                                            2
                                                                                            3
                                                                                            4
                                                                                            5
                                                                                            6
                                                                                              //JScript
                                                                                                var J,s;
                                                                                                J= new TJSONObject();
                                                                                                s= "{\"status\": true,\"Language\":{\"DefaultLanguage\": 1.1}}";
                                                                                                Try{
                                                                                                   j = TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                                   if (UGCM.GetJSONBool(j,'status'))
                                                                                                     ShowMessage('{"status": true}');
                                                                                                }
                                                                                                Finally{
                                                                                                  j.Free;
                                                                                                }
                                                                                              
                                                                                              1
                                                                                              2
                                                                                              3
                                                                                              4
                                                                                              5
                                                                                              6
                                                                                              7
                                                                                              8
                                                                                              9
                                                                                              10
                                                                                              11
                                                                                              12
                                                                                              //PasScript
                                                                                              Var 
                                                                                                J:TJSONObject;
                                                                                                s: String;
                                                                                              begin
                                                                                                J:=TJSONObject.Create;
                                                                                                s:= '{"status": true,"Language":{"DefaultLanguage": 1}}';
                                                                                                Try
                                                                                                   j := TJSONObject(j.ParseJSONValue(s,false,false));
                                                                                                   if (UGCM.GetJSONBool(j,'status')) then
                                                                                                     ShowMessage('{"status": true}');
                                                                                                Finally
                                                                                                  j.Free;
                                                                                                end;
                                                                                              end;
                                                                                              
                                                                                              1
                                                                                              2
                                                                                              3
                                                                                              4
                                                                                              5
                                                                                              6
                                                                                              7
                                                                                              8
                                                                                              9
                                                                                              10
                                                                                              11
                                                                                              12
                                                                                              13
                                                                                              14
                                                                                              15
                                                                                              // Make sure to add code blocks to your code group

                                                                                                以上程式運行后獲取到的值為{"status": true}。

                                                                                              # 3.20. GetJSONValue

                                                                                              function GetJSONValue(const QJSONObject: TJSONValue; const QPath:String):TJSONValue;
                                                                                              
                                                                                              1

                                                                                              說明: 獲取JSON對像中指定的鍵值中的值。 返回值: TJSONValue型別。

                                                                                              • GetJSONBool 函式語法中各部分說明
                                                                                              部分 說明
                                                                                              QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                              QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌

                                                                                              # 3.21. ParseJSONValue

                                                                                              function ParseJSONValue(QJson: string): TJSONValue;
                                                                                              
                                                                                              1

                                                                                              說明: 獲取字串形式的JSON對像中指定的鍵值中的值。 返回值: TJSONValue型別。

                                                                                              • GetJSONBool 函式語法中各部分說明
                                                                                              部分 說明
                                                                                              QJSONObject 要進行獲取對像操作的JSON對像名稱
                                                                                              QPath 對像在JSON中的路徑名稱,路徑的名稱之間以"."作為分隔標誌
                                                                                              系統程式
                                                                                              自定程式

                                                                                              ← 系統程式 自定程式→

                                                                                              Copyright © 2021-2025 愛招飛IsoFace | ALL Rights Reserved
                                                                                              • 跟随系统
                                                                                              • 浅色模式
                                                                                              • 深色模式
                                                                                              • 阅读模式