外部ソースのデータウィンドウをスクリプトで作成する

PowerBuilder Tips

方法

データソースに「外部ソース」を指定したデータウィンドウと同様のデータウィンドウは SyntaxFromSQL 関数でソースを生成することができません。

あらかじめ「外部ソース」のデータウィンドウオブジェクトを作成し、これを LibraryExport 関数でエクスポートしたソース構文をベースにカラムやコントロールを追記し、Create 関数でデータウィンドウを作成することができます。

下記は string (10) のカラム (dummy) をひとつだけ配置した、外部ソースのデータウィンドウの構文です。

release 17;
datawindow(units=0 timer_interval=0 color=1073741824 brushmode=0 transparency=0 gradient.angle=0 gradient.color=8421504 gradient.focus=0 gradient.repetition.count=0 gradient.repetition.length=100 gradient.repetition.mode=0 gradient.scale=100 gradient.spread=100 gradient.transparency=0 picture.blur=0 picture.clip.bottom=0 picture.clip.left=0 picture.clip.right=0 picture.clip.top=0 picture.mode=0 picture.scale.x=100 picture.scale.y=100 picture.transparency=0 processing=0 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 96 print.margin.right = 96 print.margin.top = 85 print.margin.bottom = 85 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes print.background=no print.preview.background=no print.preview.outline=yes hidegrayline=no showbackcoloronxp=no picture.file="" )
header(height=50 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
summary(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
footer(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
detail(height=60 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
table(column=(type=number updatewhereclause=yes name=dummy dbname="dummy" )
 )
text(band=header alignment="2" text="Dummy" border="0" color="33554432" x="4" y="4" height="43" width="160" html.valueishtml="0"  name=dummy_t visible="1"  font.face="MS UI Gothic" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="128" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
column(band=detail id=1 alignment="1" tabsequence=10 border="0" color="33554432" x="4" y="4" height="53" width="160" format="[general]" html.valueishtml="0"  name=dummy visible="1" edit.limit=0 edit.case=any edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="MS UI Gothic" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="128" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
htmltable(border="1" )
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" pagingmethod=0 generatedddwframes="1" )
xhtmlgen() cssgen(sessionspecific="0" )
xmlgen(inline="0" )
xsltgen()
jsgen()
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )
import.xml()
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" nativepdf.customsize=0 nativepdf.customorientation=0 nativepdf.pdfstandard=0 nativepdf.useprintspec=no )
export.xhtml()

上記の “table(column=( … ))” に記載されている部分がカラムを定義している構文です。

また、”column(band=detail id=1 …” という記載がカラムの表示や入力にかかわる構文です。これらを参考にカラムを増やすなど構文を編集して、Create 関数に渡してデータウィンドウを作成します。

・・・


table(column=(type=char(20) updatewhereclause=yes name=col01 dbname="col01" )
 column=(type=number updatewhereclause=yes name=col02 dbname="col02" )
 column=(type=datetime updatewhereclause=yes name=col03 dbname="col03" )
 )


・・・

column(band=detail id=1 alignment="0" tabsequence=10 border="0" color="33554432" x="12" y="7" height="53" width="400" format="[general]" html.valueishtml="0"  name=col01 visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="MS UI Gothic" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="128" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
column(band=detail id=2 alignment="0" tabsequence=20 border="0" color="33554432" x="424" y="7" height="53" width="400" format="[general]" html.valueishtml="0"  name=col02 visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="MS UI Gothic" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="128" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
column(band=detail id=3 alignment="0" tabsequence=30 border="0" color="33554432" x="836" y="7" height="53" width="400" format="[general]" html.valueishtml="0"  name=col03 visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="MS UI Gothic" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="128" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )

・・・

編集後の構文を Create 関数に渡し、データウィンドウを作成します。

【例】

string ls_syntax, ls_err
string ls_pbl = "c:\temp\sample.pbl" // ベースにするデータウィンドウが格納された PBL
string ls_object = "d_extsource_base" // ベースにするデータウィンドウオブジェクト名

// ベースにするデータウィンドウの構文を取得
ls_syntax = LibraryExport(ls_pbl, ls_object, ExportDataWindow!)

/* 取得した構文の編集処理 */
        
        
        

// データウィンドウを作成
dw_1.Create(ls_syntax, ls_err)

 

Tips情報

プロダクト :PowerBuilder

バージョン :2017R3

Tips 一覧を見る
PowerBuilder マイグレーション
PowerBuilder学習、動画で始めちゃう?