PCだい「ちゅき」

気がつけば庶事手伝い

目次

Blog 利用状況

ニュース

・H24/01/02
 Microsoft MVPを受賞しました
・H23/11/18
 MCTの憂鬱さんと相互リンクを張っていただきました^^
・H23/09/10
 プログラミング生放送でスピーカーさせていただきました^^ ・H22/12/18
 わんくま同盟でスピーカしました^^
さて、来年はどんな年になるかな。予想が当たるといいなぁ。
・H22/07/17
 わんくま同盟でスピーカしました^^
技術系のセッションは久しぶり。VB! VB!
・H22/03/13
 Tech FieldersでLTのスピーカしました^^
・H21/12/12
 わんくま同盟でスピーカしました^^
最近はずっとLT担当だったので、ちょっと新鮮でした^^
・H20/11/18
 Tech Fielders セミナー 大阪の
 Lightning Talkで優勝しました^^
・H20/8/23
 わんくま同盟で2回目のスピーカしちゃいました
 WCFと戯れてみました^^
・H20/5/17
 わんくま同盟でスピーカしちゃいました^^
 ちゃんとスピーカー持参しましたよんw
・H20/2/22
 なめ猫の参加証もらいました^^
・H20/1/22
 テンプレートを変えてみました^^
・H19/7/23
 ACEプログラムで、ナップサックをもらった上、工具セットももらえることになりました^^
・H19/1/11
 1が並ぶ縁起の良い日に投稿開始!。今後ともお付き合いよろしくお願いします
・H18/10/29
 参加させていただきました^^
ド・初心者ですがどうぞよろしくお願いします。

↓うーん、仕事しろ^^;
Chukiの脳内メーター

Chukiの脳内メーター

書庫

日記カテゴリ

ギャラリ

コミュニティ

相互リンク

や、やられた。動きが違う...orz 【備忘録】 64bit版 Windows Server 2008 VBSの変数宣言の挙動が違う

手持ちで64bit版がWindows Server 2008しかないため、他のバージョンでは確認できませんが、VBSの挙動の違い。
#そういえば、Windows Server 2008 x86の環境もないので未確認^^;

Vista x86版向けに作って使用していたスクリプトが動かないと思ったら...
呼び出し先関数で利用するグローバルな配列は、関数呼び出し前に宣言しないと使えません^^;


【ダメな例】

bRet = hogehoge()'ここで関数を呼び出す

Dim g_arTest()'←呼び出しより後に配列の宣言をするとダメ
Function hogehoge()

Redim Preserve g_arTest(10)'←ここで「エラー: 型が一致しません。」が発生
hogehoge = true

End Function

【動く例】

Dim g_arTest()'←呼び出しより先に配列を宣言bRet = hogehoge()'ここで関数を呼び出すFONT face=Arial>Function hogehoge()

Redim Preserve g_arTest(10)
hogehoge = true

End Function


とってもこれがバグ仕様だと思う理由。以下のコードはWindows Server 2008 x64版で動くのですよねぇorz

【動く例】配列じゃない変数はどこで宣言しても良いっぽい(きもちわるいけれど^^;)
(実行結果は当然「-1:ちゅきは一般優良市民←ここが一番の要点!

Option Explicit

szTest = "*ちゅきはウソちゅき"'←宣言前に使うのはどうか? というはないしょ^^;
Wscript.Echo hogehoge() & ":" & szTest

Dim szTest

Function hogehoge()
szTest="ちゅきは一般優良市民"
hogehoge = true
End Function


さて、改修どうしようかなぁ...(Let's say あんさっとぉ o...rz)

投稿日時 : 2008年4月13日 2:44

Feedback

# re: や、やられた。動きが違う...orz 【備忘録】 64bit版 Windows Server 2008 VBSの変数宣言の挙動が違う 2008/04/13 9:49 えすえす

vbsはほとんど触ったことがないのですが、【ダメな例】を検証してみました

結果:
Vista SP1 x64 → エラー発生
Server 2008 x86 → エラーなし

x64版だけなんでしょうか・・・

VB6っぽく考えると、グローバルな宣言が呼び出しより後にあるのは気持ち悪いですが。

# re: や、やられた。動きが違う...orz 【備忘録】 64bit版 Windows Server 2008 VBSの変数宣言の挙動が違う 2008/04/13 11:26 Chuki

えすえすさん>x64版だけなんでしょうか・・・
検証ありがとうございました。
さすが、Windows Vista Serverと site:microsoft.comで検索して引っかかるだけありますね^^;
#製品版は、Windows Vista Server SP1かな(製品版のプロパティにもSP1って書いてあるし^^;)

>VB6っぽく考えると、グローバルな宣言が呼び出しより後にあるのは気持ち悪いですが。
うん、キモイッす。
あとから関数くっつけていくうちに...

グローバル変数としてますが、運用しているのは関数内でしか使わないスタティック変数のイメージで使っています。ですので、宣言も関数の真上で行っています。
VBの宣言が、ファイルの頭だけOKという仕様から、使用前でOKと変わった時は嬉しかったんだけれどなぁ。
#事後宣言でもOKはどっちかというとバグ仕様っぽいですね^^;。でも今まで動いていたんだから、それが動かなくなるのはバグというか、仕様厳格化としてどっかに「日本語」で表記しておいてほしい^^;

# My programmer is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the expenses. But he's tryiong none the less. I've been using Movable-type on a variety of websites for about a year and am concerned about swit 2019/05/30 13:21 My programmer is trying to persuade me to move to

My programmer is trying to persuade me to move to .net from
PHP. I have always disliked the idea because of the expenses.
But he's tryiong none the less. I've been using Movable-type on a variety of websites
for about a year and am concerned about switching to another platform.
I have heard very good things about blogengine.net.

Is there a way I can import all my wordpress content into it?
Any help would be really appreciated!

# Your way of explaining the whole thing in this piece of writing is really fastidious, all be able to without difficulty be aware of it, Thanks a lot. 2019/06/05 12:53 Your way of explaining the whole thing in this pie

Your way of explaining the whole thing in this piece of writing is really
fastidious, all be able to without difficulty be aware of
it, Thanks a lot.

# Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something. I think that you can do with some pics to drive the message home a little bit, but other than that, this is magnificent blog. A fantastic read 2019/06/06 15:31 Its like you read my mind! You appear to know so m

Its like you read my mind! You appear to know so much about this,
like you wrote the book in it or something. I think that you can do with some
pics to drive the message home a little bit, but other than that, this is magnificent blog.

A fantastic read. I will definitely be back.

# Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2019/08/14 1:51 Incredible! This blog looks just like my old one!

Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much
the same page layout and design. Great choice of colors!

# Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2019/08/14 1:52 Incredible! This blog looks just like my old one!

Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much
the same page layout and design. Great choice of colors!

# Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2019/08/14 1:53 Incredible! This blog looks just like my old one!

Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much
the same page layout and design. Great choice of colors!

# Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much the same page layout and design. Great choice of colors! 2019/08/14 1:54 Incredible! This blog looks just like my old one!

Incredible! This blog looks just like my old one! It's on a entirely different topic but it has pretty much
the same page layout and design. Great choice of colors!

タイトル
名前
Url
コメント