Created
June 2, 2011 19:14
-
-
Save pbrisbin/1005081 to your computer and use it in GitHub Desktop.
Dialog maker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # makes dialog related methods for X++ | |
| # | |
| ### | |
| message() { echo './dlgmaker.sh type=variable type=variable ...'; exit 1; } | |
| [[ "$1" =~ -h|--help ]] && message | |
| args=( "$@" ) | |
| unset t | |
| unset v | |
| unset a | |
| cat << EOF | |
| class Foo extends RunBase | |
| { | |
| // variables | |
| $(for arg in "${args[@]}"; do | |
| t="${arg%=*}" | |
| v="${arg#*=}" | |
| echo -e " $t $v;" | |
| done) | |
| // dialog fields | |
| $(for arg in "${args[@]}"; do | |
| v="${arg#*=}" | |
| a="${v:0:1}" | |
| echo -e " DialogField dlg${a^^}${v:1};" | |
| done) | |
| #define.CurrentVersion(1) | |
| #localMacro.CurrentList | |
| $(for arg in "${args[@]}"; do | |
| v="${arg#*=}" | |
| echo -e " $v," | |
| done) | |
| #endMacro | |
| // NOTE: remove the final comma in the above list | |
| } | |
| EOF | |
| cat << EOF | |
| public Object dialog() | |
| { | |
| DialogRunbase dialog = super(); | |
| ; | |
| $(for arg in "${args[@]}"; do | |
| t="${arg%=*}" | |
| v="${arg#*=}" | |
| a="${v:0:1}" | |
| echo -e " dlg${a^^}${v:1} = dialog.addFieldValue(typeid($t), $v);" | |
| done) | |
| return dialog; | |
| } | |
| EOF | |
| cat << EOF | |
| public boolean getFromDialog() | |
| {; | |
| $(for arg in "${args[@]}"; do | |
| jt="${arg%=*}" | |
| v="${arg#*=}" | |
| a="${v:0:1}" | |
| echo -e " $v = ${a^^}${v:1}.value();" | |
| done) | |
| return super(); | |
| } | |
| EOF | |
| cat << EOF | |
| public container pack() | |
| {; | |
| return [#CurrentVersion, #CurrentList]; | |
| } | |
| EOF | |
| cat << EOF | |
| public boolean unpack(container packedClass) | |
| { | |
| Version version = RunBase::getVersion(packedClass); | |
| ; | |
| switch (version) | |
| { | |
| case #CurrentVersion: | |
| [version, #CurrentList] = packedClass; | |
| break; | |
| default: | |
| return false; | |
| } | |
| return true; | |
| } | |
| EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > ./dlgmaker.sh TransDate=fromDate TransDate=toDate CustAccount=custAccount ProjId=projId smmChainId=territory | |
| class Foo extends RunBase | |
| { | |
| // variables | |
| TransDate fromDate; | |
| TransDate toDate; | |
| CustAccount custAccount; | |
| ProjId projId; | |
| smmChainId territory; | |
| // dialog fields | |
| DialogField dlgFromDate; | |
| DialogField dlgToDate; | |
| DialogField dlgCustAccount; | |
| DialogField dlgProjId; | |
| DialogField dlgTerritory; | |
| #define.CurrentVersion(1) | |
| #localMacro.CurrentList | |
| fromDate, | |
| toDate, | |
| custAccount, | |
| projId, | |
| territory, | |
| #endMacro | |
| // NOTE: remove the final comma in the above list | |
| } | |
| public Object dialog() | |
| { | |
| DialogRunbase dialog = super(); | |
| ; | |
| dlgFromDate = dialog.addFieldValue(typeid(TransDate), fromDate); | |
| dlgToDate = dialog.addFieldValue(typeid(TransDate), toDate); | |
| dlgCustAccount = dialog.addFieldValue(typeid(CustAccount), custAccount); | |
| dlgProjId = dialog.addFieldValue(typeid(ProjId), projId); | |
| dlgTerritory = dialog.addFieldValue(typeid(smmChainId), territory); | |
| return dialog; | |
| } | |
| public boolean getFromDialog() | |
| {; | |
| fromDate = FromDate.value(); | |
| toDate = ToDate.value(); | |
| custAccount = CustAccount.value(); | |
| projId = ProjId.value(); | |
| territory = Territory.value(); | |
| return super(); | |
| } | |
| public container pack() | |
| {; | |
| return [#CurrentVersion, #CurrentList]; | |
| } | |
| public boolean unpack(container packedClass) | |
| { | |
| Version version = RunBase::getVersion(packedClass); | |
| ; | |
| switch (version) | |
| { | |
| case #CurrentVersion: | |
| [version, #CurrentList] = packedClass; | |
| break; | |
| default: | |
| return false; | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment