HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2014
0626
やたかdish androidで strmid 文字取り出しについて5解決


やたか

リンク

2014/6/26(Thu) 15:25:03|NO.62618

お世話になります。
dissh ver3.4b5で strmid 文字取り出しがうまくできないので教えてください。
android4.03で実機でをテストしてみました。
①のコメントをはずすと windowsで実行できない(errで終了)
5は 全角の場合5文字取り出しではなくて 半角5字分とりだしですか?
後者の場合 半角全角混合の文字列を 半角40字分を超えるとき 文字列を40字前後で2つに分けたいのですが、どうすればよいか?

②はandroid実機で 12  だけ表示される?
③念のため長さ確認すると 6で正常でした。
④はandroid実機で 123? と表示される?
以上について 原因等教えてください。 他の実機の結果も教えてください。

;―――――――――――――――― テストソース
#include "hsp3dish.as"
info_os = sysinfo(0)
if instr(info_os,0,"Windows")>=0{
flag_win=1
screen 0,480,320
}
font msmincho, 20

redraw 0
color 255, 255, 255 : boxf
color 0, 0, 0
str1="1234567890"
str2="123456789"
str3="123456789"


mes strmid(str1,0,5) ;正常

;mes strmid(str2,0,5) ;① windowsで実行できない(errで終了)
str4=strmid(str2,0,6)
mes str4 ;②androidで 12  だけ表示される?
mes str(strlen(str4)) ;③ 長さは6で正常

mes strmid(str3,0,6) ;④androidで 123? と表示される


redraw 1
stop



この記事に返信する


しまくろねこ

リンク

2014/6/26(Thu) 22:37:30|NO.62623

こんにちは。

WindowsとAndroid上では文字コードが異なるため、日本語等の文字は2バイト(Windows)ではなく3バイト(※Android)になります。
(※)一部例外もあります

なので、②と③は正常な結果となります。

また、スマホ上でstrmidと同じ機能のモジュールを私のHP上で配布しておりますので、良かったら使ってみてください。
strmidはバイト数で文字を切り出しますが、このモジュールではバイト数ではなく文字数で切り出します。

こんな感じです。

a = "123あいう"
b = gstr_mid(a, 2, 3) ;---- b = "3あい"



やたか

リンク

2014/6/27(Fri) 21:01:09|NO.62638

教えていただき、あがとうございます。
3バイトの文字コードもあるんですね。正常な動作だったようですね。
また、対応も教えていただき、さっそくモジュール使わせていただきました。
readmeのとおり設定したつもりですが、windowsで問題なく動作したのですが、
android実機でビルトしたとき
「as.exeは動作を停止しました。...」のサブウインドが出て終了してしまいました。
お手数ですが、設定のもれ等あれば教えてください。
hsp3dhでビルトしたときの結果は 下の結果でした。
Android NDK: WARNING:jni/Android.mk:hsp_y1: non-system libraries in linker flags: -lhsp3lib
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi-v7a] Compile++ thumb: hsp_y1 <= hspsource.cpp
jni/hsp3embed/hspsource.cpp: In function 'void L0001()':
jni/hsp3embed/hspsource.cpp:383:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0072()':
jni/hsp3embed/hspsource.cpp:396:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0073()':
jni/hsp3embed/hspsource.cpp:406:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:413:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:419:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:422:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:425:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:428:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:431:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:434:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:497:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0078()':
jni/hsp3embed/hspsource.cpp:62853:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:62856:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:62859:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:62862:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:62865:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:62868:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:62871:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0005()':
jni/hsp3embed/hspsource.cpp:62988:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0008()':
jni/hsp3embed/hspsource.cpp:63040:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0090()':
jni/hsp3embed/hspsource.cpp:63177:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0100()':
jni/hsp3embed/hspsource.cpp:63319:14: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0101()':
jni/hsp3embed/hspsource.cpp:63345:16: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0011()':
jni/hsp3embed/hspsource.cpp:63363:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0019()':
jni/hsp3embed/hspsource.cpp:64120:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0022()':
jni/hsp3embed/hspsource.cpp:64216:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0031()':
jni/hsp3embed/hspsource.cpp:64568:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0033()':
jni/hsp3embed/hspsource.cpp:64603:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64606:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64612:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64615:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64625:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0034()':
jni/hsp3embed/hspsource.cpp:64671:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0035()':
jni/hsp3embed/hspsource.cpp:64710:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64713:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64716:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64719:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64732:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0179()':
jni/hsp3embed/hspsource.cpp:64814:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64817:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0187()':
jni/hsp3embed/hspsource.cpp:64928:14: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0188()':
jni/hsp3embed/hspsource.cpp:64951:16: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0039()':
jni/hsp3embed/hspsource.cpp:64966:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64969:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:64991:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0190()':
jni/hsp3embed/hspsource.cpp:65008:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0036()':
jni/hsp3embed/hspsource.cpp:65065:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0042()':
jni/hsp3embed/hspsource.cpp:65363:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0045()':
jni/hsp3embed/hspsource.cpp:65459:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0048()':
jni/hsp3embed/hspsource.cpp:65674:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0054()':
jni/hsp3embed/hspsource.cpp:65829:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:65836:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0055()':
jni/hsp3embed/hspsource.cpp:65879:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0243()':
jni/hsp3embed/hspsource.cpp:66012:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0244()':
jni/hsp3embed/hspsource.cpp:66025:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0245()':
jni/hsp3embed/hspsource.cpp:66038:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0246()':
jni/hsp3embed/hspsource.cpp:66155:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66164:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66174:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66177:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0251()':
jni/hsp3embed/hspsource.cpp:66306:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0254()':
jni/hsp3embed/hspsource.cpp:66408:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66419:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66423:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66434:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66461:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66527:23: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0255()':
jni/hsp3embed/hspsource.cpp:66540:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp:66548:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0258()':
jni/hsp3embed/hspsource.cpp:66611:12: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0066()':
jni/hsp3embed/hspsource.cpp:66793:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
jni/hsp3embed/hspsource.cpp: In function 'void L0067()':
jni/hsp3embed/hspsource.cpp:66808:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s: Assembler messages:
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:24928: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:28342: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:31746: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:55471: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:72368: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:75752: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:79128: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:82512: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:103611: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:110439: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:112142: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:113845: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:137585: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:140969: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:144353: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:147737: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:157884: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:161260: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:164644: Error: offset out of range
C:\Users\ty\AppData\Local\Temp\cc758Qj2.s:168028: Error: offset out of range
make.exe: *** [obj/local/armeabi-v7a/objs/hsp_y1/hsp3embed/hspsource.o] Error 1



しまくろねこ

リンク

2014/6/27(Fri) 21:44:39|NO.62639

こんにちは。

HSPのcommonフォルダに「mod_dstr.as」が入っていれば、iniファイル「mod_dstr.ini」が無くてもビルド自体は通るかと思います。
HSP3.4β5でも確認してみましたが、モジュールを利用したテストプログラムをビルドしてみましたが、こちらではエラー無く正常にビルドされてます。
このモジュールをコメントアウトしてビルドするとどうでしょうか?(モジュールで追加された命令等もあればコメントアウト)
これでエラーが出ないのであれば、このモジュールが原因と判断できますがどうでしょうか?



やたか

リンク

2014/6/28(Sat) 07:56:21|NO.62647

しまくろねこさん、お世話になります。
今回はdstr_splitを使わせていただいてます。
1.HSPのcommonフォルダに「mod_dstr.as」が入っていること確認しました。
2.結局 ご指導とおりに、
;picmes_init
;dstr_init   にしたところ 正常に動きました。

文字数をカウントしたり、2文字で判断して文字列分割等できると大変便利で助かります。
これからもよろしくお願いします。



しまくろねこ

リンク

2014/6/29(Sun) 12:23:51|NO.62678

こんにちは。

今更で申し訳ありません。

mod_picmes.as をHSP3.4β5でビルドしてみたところ、やたかさんの言うとおり同様の現象が出ました。
私の前の書き込みでビルドが出来たのは、mod_dstr.as だけをインクルードしておりました。
mod_picmes.as を一緒にインクルードしてビルドしたところ同様の現象が出たので気がつきました。

mod_picmes.as がビルド時にエラーとなってしまうのは、最終的にDishHelperの不具合だと感じておりますが、とりあえず今のところビルドが出来ない原因としましては、mod_picmes.asのソース内で直接文字コード配列変数に落とし込んでいる処理が15,600行近くあり、この大量の行数をコメントアウトしたところDishHelperにてビルドが通りました。
そのため、設定ファイルである mod_picmes.ini から文字コードを読み込みモード(Location(celput))に変更しました。
この読み込みモードを Location(celput) にしたことにより、メリットとしては mod_picmes.as を使用したプログラムをDishHelperにてビルドしたときに、今までよりもビルド終了時間が大幅に早くなります。
逆にデメリットもあります。デメリットとしては、初期化命令である picmes_init を使用したときに picmes_init 命令が終了するまでの時間が今までよりも長くなります。

とり急ぎではありますが、問題を修正した mod_picmes.as(Ver3.421) をHPにてダウンロードできるようにしました。
書いている意味が解かりにくいかとは思いますが、Ver3.421に入れ替えてもらえれば、とりあえずHSP3.4β5でもビルド可能になります。



ONION software Copyright 1997-2023(c) All rights reserved.