SlideShare a Scribd company logo
1 of 19
Download to read offline
まもなく開始します。

13年3月16日土曜日
変数を使ってみよう
      変数を使ったことがありますか?データベース構造と
      は関係なく値を格納できる便利な変数。変数には ロ
      ーカル変数 と グローバル変数 の2種類があります。




13年3月16日土曜日
本日の内容
         変数とは?

         変数の定義

         変数の使いどころ

         実践(ワークショップ)

         便利な変数の使い方



13年3月16日土曜日
変数とは
         計算式で、値を表すシンボルまたは名前。変数の設定
         スクリプトステップを使用し、変数の名前、値および
         繰り 返しを指定します。名前に $ で接頭語を付ける
         と、現在のスクリプト内でのみ使用できるローカル変
         数になります。名前に $$ で接頭語を付けると現在のフ
         ァイル全体で使用できるようになります。ローカルおよ
         びグローバルな変数は同じ名前にすることができます
         が、異なる変数として 処理されます。


13年3月16日土曜日
変数の種類
         ローカル変数 $_XXX

              計算式・スクリプト中のみ保持される

         グローバル変数 $$_XXX

              ファイルが閉じられるまで保持される

         Let 関数内の変数

              計算式内のみで保持される


13年3月16日土曜日
グローバル変数のマージ


         <<$$_XXX>> の形式でレイアウト上に配置

              グローバル変数の値を表示できる

              Ver. 12 以降




13年3月16日土曜日
変数に使える文字
         2バイト文字が使える(日本語も大丈夫)

              「$」はダメ

              大文字・小文字を区別しない

              命名時の制約はテーブル/フィールド名と同じ

               変数の場合、強制もできない

              「変数を設定」スクリプトステップの名前入力欄で
              はローカル変数の「$」を省略しても大丈夫
13年3月16日土曜日
問題01


         グローバル変数とローカル変数の名前を同じにした
         場合、値は同じになる?

              例:$$時間 $時間




13年3月16日土曜日
問題01:答え

         グローバル変数とローカル変数の名前を同じにした
         場合、値は同じになる?

              答え:同じ値にならない

              グローバル変数とローカル変数は名前が同じでも
              別の変数として扱われる



13年3月16日土曜日
問題02


         ローカル変数はスクリプト内の「スクリプトの実
         行」スクリプトステップで呼び出した別のスクリプ
         ト内でも保持される?




13年3月16日土曜日
問題02:答え
         ローカル変数はスクリプト内で「スクリプトの実
         行」スクリプトステップで呼び出した別のスクリプ
         ト内でも保持される?

              答え:保持されない

              ローカル変数は定義したスクリプト内のみで有
              効。



13年3月16日土曜日
問題03


         メインスクリプトで定義したローカル変数と同じ名
         前のローカル変数をサブスクリプトでも定義して値
         を変更した場合、メインスクリプトに戻ってきた時
         に変数の値はどうなる?




13年3月16日土曜日
問題03:答え
         メインスクリプトで定義したローカル変数と同じ名
         前のローカル変数をサブスクリプトでも定義して値
         を変更した場合、メインスクリプトに戻ってきた時
         に変数の値はどうなる?

              答え:メインスクリプトで定義した時の値のまま

              ローカル変数の値はスクリプト内でのみ保持さ
              れるので、別のスクリプトで同じ変数名を使って
              も元のスクリプトでは保持されたまま
13年3月16日土曜日
本日の質問

         スクリプトの結果を受け取るには?

              答え:「現在のスクリプト終了」スクリプトステ
              ップで”スクリプトの結果”を設定すると、元のスク
              リプトで Get ( スクリプトの結果 ) で受け取れる




13年3月16日土曜日
本日の質問

         ファイルをまたいで変数を使える?

              ローカル/グローバルともにファイルをまたぐこと
              はできない

               スクリプト引数やスクリプトの結果を使うこと
               で値の受け渡しはできる



13年3月16日土曜日
変数を定義するには

         「変数を設定」スクリプトステップ

         Let 関数を使う(フィールド定義)

         Let 関数を使う(条件付き書式)

         データビューワ(Advancedのみ)




13年3月16日土曜日
変数の扱いのポイント
              変数は最初の定義以外はコピー&ペーストが原則

              名前を覚えて「$_XXX」と打たない

              面倒だけどミスの発生率が桁違い

              手打ちだとミスがあった場合に発見が困難

               InspectorとかBaseElements使う?



13年3月16日土曜日
変数の落とし穴

         ローカル変数はスクリプト内のみで保持されるが、
         スクリプトステップ以外で再定義される場合がある

              スクリプト内でのレコード移動/レイアウト切替で
              計算式内の変数が変更されると、スクリプト内の
              同名の変数に影響が出る




13年3月16日土曜日
変数の使いどころ
         値の作成・保存

         動的なパスの作成

         繰り返しの処理(カウンターとして使う)

         繰り返しの処理(繰り返し変数)

         スクリプトの効率化

         開発の効率化

         マージ変数でレイアウトの使い回し
13年3月16日土曜日

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

FM-中部 2013.3.16 変数を使ってみよう

  • 2. 変数を使ってみよう 変数を使ったことがありますか?データベース構造と は関係なく値を格納できる便利な変数。変数には ロ ーカル変数 と グローバル変数 の2種類があります。 13年3月16日土曜日
  • 3. 本日の内容 変数とは? 変数の定義 変数の使いどころ 実践(ワークショップ) 便利な変数の使い方 13年3月16日土曜日
  • 4. 変数とは 計算式で、値を表すシンボルまたは名前。変数の設定 スクリプトステップを使用し、変数の名前、値および 繰り 返しを指定します。名前に $ で接頭語を付ける と、現在のスクリプト内でのみ使用できるローカル変 数になります。名前に $$ で接頭語を付けると現在のフ ァイル全体で使用できるようになります。ローカルおよ びグローバルな変数は同じ名前にすることができます が、異なる変数として 処理されます。 13年3月16日土曜日
  • 5. 変数の種類 ローカル変数 $_XXX 計算式・スクリプト中のみ保持される グローバル変数 $$_XXX ファイルが閉じられるまで保持される Let 関数内の変数 計算式内のみで保持される 13年3月16日土曜日
  • 6. グローバル変数のマージ <<$$_XXX>> の形式でレイアウト上に配置 グローバル変数の値を表示できる Ver. 12 以降 13年3月16日土曜日
  • 7. 変数に使える文字 2バイト文字が使える(日本語も大丈夫) 「$」はダメ 大文字・小文字を区別しない 命名時の制約はテーブル/フィールド名と同じ 変数の場合、強制もできない 「変数を設定」スクリプトステップの名前入力欄で はローカル変数の「$」を省略しても大丈夫 13年3月16日土曜日
  • 8. 問題01 グローバル変数とローカル変数の名前を同じにした 場合、値は同じになる? 例:$$時間 $時間 13年3月16日土曜日
  • 9. 問題01:答え グローバル変数とローカル変数の名前を同じにした 場合、値は同じになる? 答え:同じ値にならない グローバル変数とローカル変数は名前が同じでも 別の変数として扱われる 13年3月16日土曜日
  • 10. 問題02 ローカル変数はスクリプト内の「スクリプトの実 行」スクリプトステップで呼び出した別のスクリプ ト内でも保持される? 13年3月16日土曜日
  • 11. 問題02:答え ローカル変数はスクリプト内で「スクリプトの実 行」スクリプトステップで呼び出した別のスクリプ ト内でも保持される? 答え:保持されない ローカル変数は定義したスクリプト内のみで有 効。 13年3月16日土曜日
  • 12. 問題03 メインスクリプトで定義したローカル変数と同じ名 前のローカル変数をサブスクリプトでも定義して値 を変更した場合、メインスクリプトに戻ってきた時 に変数の値はどうなる? 13年3月16日土曜日
  • 13. 問題03:答え メインスクリプトで定義したローカル変数と同じ名 前のローカル変数をサブスクリプトでも定義して値 を変更した場合、メインスクリプトに戻ってきた時 に変数の値はどうなる? 答え:メインスクリプトで定義した時の値のまま ローカル変数の値はスクリプト内でのみ保持さ れるので、別のスクリプトで同じ変数名を使って も元のスクリプトでは保持されたまま 13年3月16日土曜日
  • 14. 本日の質問 スクリプトの結果を受け取るには? 答え:「現在のスクリプト終了」スクリプトステ ップで”スクリプトの結果”を設定すると、元のスク リプトで Get ( スクリプトの結果 ) で受け取れる 13年3月16日土曜日
  • 15. 本日の質問 ファイルをまたいで変数を使える? ローカル/グローバルともにファイルをまたぐこと はできない スクリプト引数やスクリプトの結果を使うこと で値の受け渡しはできる 13年3月16日土曜日
  • 16. 変数を定義するには 「変数を設定」スクリプトステップ Let 関数を使う(フィールド定義) Let 関数を使う(条件付き書式) データビューワ(Advancedのみ) 13年3月16日土曜日
  • 17. 変数の扱いのポイント 変数は最初の定義以外はコピー&ペーストが原則 名前を覚えて「$_XXX」と打たない 面倒だけどミスの発生率が桁違い 手打ちだとミスがあった場合に発見が困難 InspectorとかBaseElements使う? 13年3月16日土曜日
  • 18. 変数の落とし穴 ローカル変数はスクリプト内のみで保持されるが、 スクリプトステップ以外で再定義される場合がある スクリプト内でのレコード移動/レイアウト切替で 計算式内の変数が変更されると、スクリプト内の 同名の変数に影響が出る 13年3月16日土曜日
  • 19. 変数の使いどころ 値の作成・保存 動的なパスの作成 繰り返しの処理(カウンターとして使う) 繰り返しの処理(繰り返し変数) スクリプトの効率化 開発の効率化 マージ変数でレイアウトの使い回し 13年3月16日土曜日