4D v18

Appendix: 変換に使える便利メソッド

ホーム

 
4D v18
Appendix: 変換に使える便利メソッド

Appendix: 変換に使える便利メソッド    


 

インデックスされていない重複不可フィールドをディスクファイルに出力するための TechTip です:

 C_LONGINT($maxTableNumber_l;$currentTable_l)
 C_LONGINT($maxFieldCount_l;$currentField_l)
 C_LONGINT($dontCare_l// 使用しない GET FIELD PROPERTIES の値用
 C_BOOLEAN($dontCare_f;$isIndexed_f;$isUnique_f)
 C_TEXT($logHeader_t;$logRecord_t;$logfile_t)
 C_TEXT($delim_t;$lf_t)
 C_TIME($logfile_h)
 C_TEXT($tableName_t;$fieldName_t;$note_t)
 
 $delim_t:=Char(Tab)
 $lf_t:=Char(Carriage return)+Char(Line feed)
 
 $logHeader_t:="Unique fields without index:"+$lf_t
 
 $logfile_t:=Get 4D folder(Logs folder)+"UniqueNotIndexed.txt"
 
 $logfile_h:=Create document($logfile_t)
 
 If(OK=1)
 
    SEND PACKET($logfile_h;$logHeader_t)
 
    $maxTableNumber_l:=Get last table number
 
    For($currentTable_l;1;$maxTableNumber_l)
       If(Is table number valid($currentTable_l))
          $maxFieldCount_l:=Get last field number(Table($currentTable_l))
          For($currentField_l;1;$maxFieldCount_l)
             If(Is field number valid($currentTable_l;$currentField_l))
 
  // 次の行は途中で改行されている点に注意してください:
                GET FIELD PROPERTIES($currentTable_l;$currentField_l;$dontCare_l;\
                $dontCare_l;$isIndexed_f;$isUnique_f;$dontCare_f)
 
                If(($isUnique_f) & (Not($isIndexed_f)))
 
                   $tableName_t:=Table name(Table($currentTable_l))
                   $fieldName_t:=Field name(Field($currentTable_l;$currentField_l))
 
                   $logRecord_t:="["+$tableName_t+"]"+$fieldName_t+$lf_t
 
                   SEND PACKET($logfile_h;$logRecord_t)
 
                End if
             End if
          End for
       End if
    End for
 
    CLOSE DOCUMENT($logfile_h)
    SHOW ON DISK($logfile_t)
 End if

インデックスされていない重複不可フィールドをインデックスするための TechTip です

 C_LONGINT($maxTableNumber_l;$currentTable_l)
 C_LONGINT($maxFieldCount_l;$currentField_l)
 C_LONGINT($dontCare_l// 使用しない GET FIELD PROPERTIES の値用
 C_BOOLEAN($dontCare_f;$isIndexed_f;$isUnique_f)
 C_TEXT($logHeader_t;$logRecord_t;$logfile_t)
 C_TEXT($delim_t;$lf_t)
 C_TIME($logfile_h)
 C_TEXT($tableName_t;$fieldName_t;$note_t)
 
 
 $maxTableNumber_l:=Get last table number
 
 For($currentTable_l;1;$maxTableNumber_l)
    If(Is table number valid($currentTable_l))
       $maxFieldCount_l:=Get last field number(Table($currentTable_l))
       For($currentField_l;1;$maxFieldCount_l)
          If(Is field number valid($currentTable_l;$currentField_l))
 
  // 次の行は途中で改行されている点に注意してください:
             GET FIELD PROPERTIES($currentTable_l;$currentField_l;$dontCare_l;\
             $dontCare_l;$isIndexed_f;$isUnique_f;$dontCare_f)
 
             If(($isUnique_f) & (Not($isIndexed_f)))
 
                $tablePtr:=Table($currentTable_l)
                $fieldPtr:=Field($currentTable_l;$currentField_l)
                $tableName_t:=Table name($tablePtr)
                $fieldName_t:=Field name($fieldPtr)
                $indexName_t:="["+$tableName_t+"]"+$fieldName_t+" indexed for uniqueness (kb#77023)"
                ARRAY POINTER($fieldsArray_p;1)
                $fieldsArray_p{1}:=$fieldPtr
                CREATE INDEX($tablePtr->;$fieldsArray_p;Standard BTree Index;$indexName_t;*)
 
             End if
          End if
       End for
    End if
 End for

ピクチャーの変換は 64-bit に移行するに、32-bit バージョンにて行います。

1 - フォーム上のスタティックピクチャーをピクチャーライブラリに移動します:
(Tips: スタティックピクチャーをライブラリピクチャーへと変換する)



2 - PICT画像をPNG画像 (または JPEG画像) へと変換します:
(Tips: PICT画像をPNG画像へと変換するユーティリティ)

 C_LONGINT($i;$SOA;$RIS;$PictRef)
 C_TEXT($PictName)
 C_PICTURE($Pict)
  //------------ 配列の初期化 ------------------
 ARRAY LONGINT($aL_PictRef;0)
 ARRAY TEXT($aT_PictName;0)
 ARRAY TEXT($at_Codecs;0)
 PICTURE LIBRARY LIST($aL_PictRef;$aT_PictName)
 $SOA:=Size of array($aL_PictRef)
  //------------ PICT画像をPNG画像に変換 ------------------
 If($SOA>0)
    For($i;1;$SOA// 画像ごとに
       $PictRef:=$aL_PictRef{$i}
       $PictName:=$aT_PictName{$i}
       GET PICTURE FROM LIBRARY($aL_PictRef{$i};$Pict)
       GET PICTURE FORMATS($Pict;$at_Codecs)
       For($j;1;Size of array($at_Codecs))
          If($at_Codecs{$j}=".pict") // PICT画像であれば
             CONVERT PICTURE($Pict;".png") // PNG画像に変換
  // ライブラリに保存
             SET PICTURE TO LIBRARY($Pict;$PictRef;$PictName)
          End if
       End for
    End for
 Else
    ALERT("イメージライブラリが空です。")
 End if
  //------------ end of method ------------------

注記: これは、フランス語の言語設定でメソッドを記述したい場合に必要となる処理です。

組み込みアプリケーションを運用する際に、リージョン設定を有効にするには各マシンの 4D v1x preferences ファイルを編集し、"use_localized_language" キーを "true" に設定する必要があります (コマンドと定数に使用する言語 参照)。

 $UserPreference:=Get 4D folder(Active 4D Folder)+"4D Preferences v17.4DPreferences"
 $ref:=DOM Parse XML source($UserPreference;True)
 $refElem:=DOM Find XML element($ref;"preferences/com.4d/method_editor/options";arrElementRefs)&NBSP// 現在の値を取得
 DOM GET XML ATTRIBUTE BY NAME($refElem;"use_localized_language";$attrValue)
 if($attrValue="false") // False であれば
    DOM SET XML ATTRIBUTE($refElem;"use_localized_language";"true")
 End if
 DOM EXPORT TO FILE($ref;$UserPreference)
 DOM CLOSE XML($ref)

 
 

 
プロパティ 

プロダクト: 4D ODBC Pro
テーマ: Appendix: 変換に使える便利メソッド

 
履歴 

 
ARTICLE USAGE

4D v18への変換 ( 4D v18)