このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


DLLs: 中間の level help on using 機能(する)/行事s and 手続きs from them in ooCalc, etc- Open Office Tutorials - opof6dll2 AUTHOR'S MAIN SITE   > > > > >   TABLE OF CONTENTS for Open Office database tutorials.
MACROS section, Open Office tutorials.    -d- Bookmark on Delicious    Recommend to StumbleUpon

Open Office Tutorials- 大型のs...

Using them to create and 接近
使用者 defined 機能(する)/行事s and subroutines
中間の level tutorial

This page is one of several trying to help you get the most out of the splendid Open Office. They are 連合した with a larger 始める,決める concentrating on ooBase.

Remember that Open Office, 含むing ooBase, is 解放する/自由な! But don't let that fool you. And it's not new. Big organizations, 政府 and 非軍事の, are 可決する・採択するing it as their 基準 office 控訴... and saving million$, and still Getting The 職業 Done.

There's more about ooBase in the main 索引 to this 構成要素.

This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a 狭くする window. With most browsers, 圧力(をかける)ing 加える, minus or 無 while the 支配(する)/統制する 重要な (ctrl) is held 負かす/撃墜する will change the texts size. (大きくする, 減ずる, 回復する to default, それぞれ.) (This is more fully explained, and there's another tip, at my 力/強力にする Browsing page.)

Page contents © TK Boyd, Sheepdog ソフトウェア ®, 11/11.



Introduction

This tutorial is written for an audience that is already reasonably comfortable with OpenOffice 大型の work. If you 港/避難所't done much with 大型のs, you might want to visit some of my "getting started with 大型のs" tutorials. The tutorial you are looking at now is at an 中間の level. If it isn't telling you new things, try my 前進するd tutorial on 使用者 defined 機能(する)/行事s, even 接近ing 機能(する)/行事s and subroutines in 外部の DLLs.

ありふれた introduction

If you have read my 前進するd "using 機能(する)/行事s and 手続きs from DLLs" tutorial, the next few paragraphs will look familiar... much of the 構成要素 appears in both tutorials because I can't be sure that every reader will read these tutorials in the same order.

This tutorial is going to show you how 使用者 defined 機能(する)/行事s can be created and used in an Open Office 文書. In the tutorial, I am going to be using an ooCalc worksheet... but the 原則s 適用する to other Open Office 文書s, too. And you might even find that what we are doing here would work in Excel... but I make no 約束s, as ooCalc takes care of all my spreadsheet needs without the expense of supporting Microsoft!

The 機能(する)/行事s used for the examples aren't very exciting, but they should be enough to get you started, help you with creating 機能(する)/行事s you do want.



Creating and using a 使用者 defined 機能(する)/行事

A 機能(する)/行事 is something that "returns" a value. Our first 使用者 created 機能(する)/行事 is going to return "Hello World" any time we invoke the 機能(する)/行事. Don't worry... later 機能(する)/行事s will be more "useful".

Start up a new, empty, ooCalc worksheet. We're going to go rather slowly at first, just to cover some basics "gotchas", but don't go to sleep... the pace 選ぶs up before long.

I was using Open Office 3.0.0 on a Windows XP machine, by the way, but that shouldn't 事柄. Tell me, if something about your system makes what follows incorrect, please?

Save your worksheet as TstUserCreatedFunctionEasy.

(In this work, you will find ooCalc "doing things" to your capitalizations... just type what I 示唆する, but don't worry too much when ooCalc changes things on you! But remember that there ARE places in 大型の work where the 事例/患者 DOES 事柄, e.g. MyVariable isn't always 受託するd if MYVARIABLE is what is 手配中の,お尋ね者. 避ける using ALL CAPS, or all-lower-事例/患者, but don't "fight" the machine.)

Once again... for a while... the 構成要素 below will seem familiar if you've read my harder 'Open Office and DLLs' tutorial. Don't worry... this time we will go on to some more 平易な things, instead of going over the 辛勝する/優位 into the コンビナート/複合体 ones!

Invoke....

道具s | 大型のs| 組織する 大型のs | OpenOffice.org Basic...

... which will open a dialog. In the left 手渡す pane, 演習 負かす/撃墜する (you'll click on a little "+" 調印する at one point.. or 二塁打-click on a "folder" 指名する) to TstUserCreatedFunctionEasy.ods/基準. Click on the "New" button. This will let you create a new "module". 割り当てる "tkbUsrFuncs" as its 指名する. (If you save your 大型の modules inside the 文書, as we are going to do here, you can have different 始める,決めるs of 大型のs for different 状況/情勢s, and the modules can even have the same 指名する.). Don't go off there now and get distracted from the joys of using 大型のs, and using 機能(する)/行事s and 手続きs from 外部の DLLs, but when you're ready, I've done 公式文書,認めるs for you on the プロの/賛成のs and 反対/詐欺s of the ways to saving Open Office 大型のs in different places.(That link will open in a new tab or window, if you want to get it 負担d now for later 言及/関連.)) As soon as you've done that, a window will open. It will have...

REM  *****  BASIC  *****

Sub Main

End Sub

... already typed for you; that is a 骸骨/概要 for a 大型の.

Rather than a 大型の, we're creating a 使用者 defined 機能(する)/行事. But we're going to do it "in" the "part" of ooCalc 始める,決める up for doing 大型のs. That's okay... just a little 混乱させるing, maybe.

Our first 機能(する)/行事 isn't going to do very much... Just return the 伝統的な "Hello World". (Something very like it has a 価値のある use: You can make a 使用者 defined 機能(する)/行事 報告(する)/憶測 the 見解/翻訳/版 ID for collections of 機能(する)/行事s you've put together.)

取って代わる EVERYTHING that the system "pre-typed" for you with....

機能(する)/行事 tkbHello()
tkbHello="Hello World"
end 機能(する)/行事

That will create a new 機能(する)/行事, 利用できる to this worksheet (not across all your ooCalc work... but while we're finding our feet, we don't want to "mess with" the underlying, 全世界の, 取り付け・設備 of ooCalc, do we?) which will 追加する two numbers.

In the "edit 大型の" window, where we've just created our 使用者-defined 機能(する)/行事, find the "収集する" button (first on my toolbar... three "sheets of paper" in a stack, with a blue arrow pointing 負かす/撃墜する.)

Click it. You should see nothing. If you have typos, you may get an error message.

At this 行う/開催する/段階, I would be inclined to click とじ込み/提出する| Save... but you don't have to. Leave the "大型の" editing window (which we are using to edit a 機能(する)/行事) open, go 支援する to the main worksheet window.

Enter....

=tkbHello()

... in a 独房, and 圧力(をかける) "Enter"... "Hello World" (without the quotation 示すs) should appear in the 独房. 公式文書,認める the "()" after the "tkbHello". For this simple 機能(する)/行事, the parentheses are empty, but you still need them in the contents of the 独房 which calls the 機能(する)/行事. It is part of how ooCalc knows that "tkbHello" is a 機能(する)/行事. Later we are going to put things inside the parentheses.

出口 out of all you've done, 説 "Save" if you get a "you've made changes, don't you want to save them?" 警告.

Re-open the worksheet. You may 井戸/弁護士席 get a "This 文書 含む/封じ込めるs 大型のs.... 死刑執行 of 大型のs is 無能にするd..." message.

If you do, follow the 指示/教授/教育s for enabling 大型のs 死刑執行, re-の近くに the worksheet, re-open it. (I wish I could show you how to 永久的に 権限を与える 大型の 死刑執行 at a 文書-by-文書 level. However, the "medium" 安全 level seems good to me. It will be tedious to say "yes, okay" each time I open a worksheet with 大型のs... but I don't use them much (yet), and it will create a tripwire if someone tries to (打撃,刑罰などを)与える a malicious 大型の on me.)

Start made

Fancier 使用者 Defined 機能(する)/行事s

So far, so good... but we're now going on to 使用者 defined 機能(する)/行事s which are a little harder to make and use... but which are more useful, once made!

Here's what's coming up....

We're going to create more 使用者 defined 機能(する)/行事s. They are going to be defined in the same 大型の コンテナ we used above

Our new 使用者 defined 機能(する)/行事s are going to be fancier, because we're going to pass numbers to them, and the answer we get 支援する will change depending on our "input"

First "fancy" 使用者 defined 機能(する)/行事: tkbDoubleIt

Suppose that you were doing some spreadsheet work, and that it would be helpful to have a way to 二塁打 any number.

Along the road to that, put the number 12 in 独房 A5 of the worksheet we were working with earlier, the one with your tkbHello() 使用者 defined 機能(する)/行事.

Put =A5*2 in 独房 B5, and you should see 24

There's already a way to see what twice something is. That's not the point. Our example may 遂行する something "trivial"... but I don't want anything to distract from how we do what we're going to do.

Put =tkbDoubleIt(A5) in B5, but don't be alarmed by whatever error message you get. (You'll probably see "#NAME"? in the 独房 after you 完全にする entering the 決まり文句/製法.) OpenOffice's spreadsheet doesn't have a "tkbDoubleIt" 機能(する)/行事... yet.

Once again use 道具s| 大型のs| 組織する 大型のs| OpenOffice.org Basic (and some 演習ing 負かす/撃墜する) to 再開する the 大型の module you created earlier, tkbUsrFuncs. You should find that...

機能(する)/行事 tkbHello()
tkbHello="Hello World"
end 機能(する)/行事

.. is still there.

Now 追加する the に引き続いて....

機能(する)/行事 tkbDoubleIt(a)
tkbDoubleIt=a*2
end 機能(する)/行事

Click on the "収集する" button. (This is probably optional, if you can't find it easily. It is a quick way to catch some boo-boos, if you can find the "収集する" button.)

Now click again on the worksheet. No changes are 明らかな. But! Click on B5, the 独房 持つ/拘留するing =TKBDOUBLEIT(A5). Don't worry about the annoying fact that ooCalc put everything into upper 事例/患者 letters. 圧力(をかける) F2, to enter "edit 方式". 圧力(をかける) backspace, which should get rid of the ")" at the 権利 手渡す end of TKBDOUBLEIT(A5). 圧力(をかける) the ")" 重要な to put the parenthesis 支援する again. 圧力(をかける) the enter 重要な, to finish "editing" the contents of A5. (It was a pretty feeble "edit"... you started to make a change, put things 支援する to how they were before, and left the edit 方式. But that's enough to "trick" ooCalc into re-calculating the contents of the 独房... and you should now see 24! Hurrah! tkbDoubleIt() is working!

Our 使用者 defined 機能(する)/行事 "takes an argument", and "returns a value". Change what you have in 独房 A5. If you make it, say, 22, the contents of B5 should change too. (To 44, if you put 22 in A5, 権利?)

We're done with tkbDoubleIt(), probably. Let me ramble on just a moment more about "arguments".

Think about the 基準 ooCalc 機能(する)/行事 "SQRT", which returns the square root of whatever argument you pass to it.

Put =SQRT(36) in 独房 E5, and you should get 6.

Put 36 in 独房 D5, and =SQRT(D5) in 独房 E5, and you should still get 6 in E5. Change what's in D5, and what's in E5 should change.

This is just the normal 操作/手術 of an ooCalc 機能(する)/行事 (SQRT()). When you use your 使用者 defined tkbDoubleIt(), it is working just like the built in 機能(する)/行事s.

Second "fancy" 使用者 defined 機能(する)/行事: tkbWithTax

The 機能(する)/行事 tkbHello() has the parentheses after it to help the system realize that it is a 機能(する)/行事, but you never put anything between them.

The 機能(する)/行事s SQRT() and tkbDoubleIt() both need a number inside the parentheses.... one number. And there are many other 機能(する)/行事s like them.

The 機能(する)/行事 TRIM() needs a string between the parentheses. TRIM() gets rid of any 主要な or training spaces. Again, it is a 選び出す/独身 argument 機能(する)/行事, but one that 要求するs (and returns) a string, rather than 要求するing or returning a number.

The 機能(する)/行事 LEN() is passed a string, and returns a number. (It 報告(する)/憶測s the LENgth of the string.)

And so on.

There are also 機能(する)/行事s to which you pass more than one argument, and we're going to make a 使用者 defined example of one of those.

Put tkbWithTax(200;3) in 独房 A6. As before, because ooCalc doesn't yet know about the tkbWithTax, which we are just about to create.

A "little 詳細(に述べる)"... the sort that 定期的に costs computer 使用者s hours of 失望/欲求不満: The two numbers inside the parentheses are separated by a 半分-結腸, no the 結腸 you might 推定する/予想する.

tkbWithTax is going to return 206 if you pass it 200;3. It will tell you the cost of something with 税金 if you pass it the cost without 税金, and the 税金 率.

Go 支援する into 大型の module tkbUsrFuncs.

追加する to it...

機能(する)/行事 tkbWithTax(without,率)
tkbWithTax=without+(without*率/100)
end 機能(する)/行事

Go 支援する, as before, and "軽く押す/注意を引く" the contents of A6. You should get 206, the price, with a 3% 税金, of something which cost $200, without 税金.

If after you've 追加するd the 機能(する)/行事 鮮明度/定義 to the 大型のs module, and 軽く押す/注意を引くd the contents of A6, you get "#NAME?", 二塁打 check your typing. (Using copy/ paste is usually best, but be sure to 熟考する/考慮する what you've copy/pasted!). No mistakes?

Look at what you put in A6. Did you put...

=tkbWithTax(200;3)

... or did you put....

=tkbWithTax(200,3)

??? See the difference? It's the 賭け金-penultimate character... 権利: semicolon. Wrong: comma. I 現実に, really, truly made 正確に/まさに that mistake while doing this 演習 と一緒に 令状ing this tutorial. It is an 平易な way to go wrong.

You don't have to "hardcode" the arguments of a call to tkbWithTax() any more than you have to hardcode the argument to a call of tkbDoubleIt() or Sqrt(). Here's an example that may be 利益/興味ing...

Put the phrase "税金 率" in A10.

Put 3 in B10. It will be the 税金 率 for some 計算/見積りs to come.

In A11, A12, A13, それぞれ, put....

200
2000
500
543

And now in B11 put...

=tkbWithTax(A11;$B$10)

.. and you should すぐに get 206 in B11.

Now for the clever bit... and the bit that was why we put the dollar 調印するs in $B$10....

Make sure you aren't still editing the contents of B11... 圧力(をかける)ing the enter 重要な should take care of that.

権利-click on B11, and click on "Copy" in the pop-up menu.

Drag across 独房s B12, B13 and B14, which should leave them both selected. 権利-click inside one or the other, and this time click "Paste" from the pop-up menu.

Presto! You should now see....

税金 率     3
--------------
200        206
2000      2060
500        515
543        559.29

Ta da! The prices of a bunch of things, before and after 税金. Change JUST the 税金 率... and see what happens to the four "with 税金" 人物/姿/数字s.

It isn't really a part of 使用者 defined 機能(する)/行事s, but let me just について言及する in passing what made that little bit of 魔法 work...

When I pasted =tkbWithTax(A11;$B$10), which I copied from B11, into B12, B13, B14, I got the に引き続いて....

=tkbWithTax(A12;$B$10)
=tkbWithTax(A13;$B$10)
=tkbWithTax(A14;$B$10)

The first 称する,呼ぶ/期間/用語 is changed during the "paste" 過程 to 補償する for the new 場所. The second 称する,呼ぶ/期間/用語, because of the dollar 調印するs, is NOT changed during the paste 過程... so all of the 計算/見積りs use the "税金 率" 人物/姿/数字 from B10, even though the without-税金 人物/姿/数字 it is 存在 適用するd to comes from different 独房s in each instance.

Enough $ 転換!

One last time: Between the arguments passed with a 機能(する)/行事: semicolon, not commas.

That's all, folks!

That just about does it, I hope? I nearly threw in a little bit about putting a 大型の in the 大型の module. 大型のs "do things" 反して 機能(する)/行事s, as you learned above, return values. What sort of things go 大型のs do? They can 原因(となる) little messages to pop up, they can go through a worksheet changing things. Etc, etc. But I realized just in time that there is a separate and 完全にする tutorial all about using 大型のs, so I didn't repeat that here. Whew.




If you are like Oliver, and want "More...."

I hope that was useful? If you are ready to go even その上の, try my 前進するd tutorialon using 機能(する)/行事s embedded in 外部の DLLs!

But take a break, first... You've earned it!





編集(者)の Philosophy

I dislike 'fancy' websites with more 関心 for a flashy 外見 than for good content. For a pretty picture, I can go to an art gallery. Of course, an attractive 場所/位置 WITH content deserves 賞賛する... as long as that pretty 直面する doesn't cost download time. In any 事例/患者....

I am trying to 現在の this 構成要素 in a 判型 which makes it 平易な for you to USE it. There are two 面s to that: The way it is 分裂(する) up, and the way it is 地位,任命するd. See the main 索引 to this 構成要素 for more (警察などへの)密告,告訴(状) about the way it is 分裂(する) up, and the way it is 地位,任命するd.


広告 from page's editor: Yes.. I do enjoy 収集するing these things for you... I hope they are helpful. However.. this doesn't 支払う/賃金 my 法案s!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and 循環させる it for me? Links on your page to this page would also be 高く評価する/(相場などが)上がるd!

PLEASE >>> Click here to visit editor's Sheepdog ソフトウェア (tm) freeware, shareware pages <<< PLEASE


If you liked this ooBase tutorial, see the main 索引 for (警察などへの)密告,告訴(状) other help from the same author.

Editor's email 演説(する)/住所. Suggestions welcomed!     - - -    Want a 場所/位置 hosted, or email? I like 1&1's services.




Valid HTML 4.01 Transitional Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org


One last bit of advice: Be sure you know all you need to about spyware.

. . . . . P a g e . . . E n d s . . . . .