UBound

構文
  1. Integer = UBound( 配列 )
引数
配列
上限値を求める配列
戻値
配列の上限値

プログラム

////////////////////////////////////////////////// // 【引数】 // 配列 : 上限値を求める配列 // 【戻値】 // 配列の上限値 ////////////////////////////////////////////////// FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND

プログラム実行例

ハイアンドロー

DIM cards[-1] DIM mark[3] = "♠", "♥", "♣", "♦" FOR item IN mark FOR n = 1 TO 13 arrayPush(cards, item + n) NEXT NEXT FisherYates(cards) FOR n = 0 TO UBound(cards) - 1 DIM res = SLCTBOX(SLCT_BTN OR SLCT_NUM, 0, "次のカードは「 " + cards[n] + " 」よりHIGH、LOW?", "HIGH", "LOW") PRINT cards[n] + "<#TAB>" + COPY(cards[n], 2) PRINT cards[n+1] + "<#TAB>" + COPY(cards[n+1], 2) DIM before = VAL(COPY(cards[n], 2)) DIM after = VAL(COPY(cards[n+1], 2)) IF res = 0 THEN operator = "<" IF res = 1 THEN operator = ">" res = IIF(before + operator + "=" + after, "正解", "不正解") PRINT res IF res = "不正解" THEN EXIT PRINT "----------" NEXT MSGBOX("全問正解!!!") ////////////////////////////////////////////////// // 【引数】 // array : 要素を追加する配列(参照引数) // str : 追加する要素 // 【戻値】 // 処理後の配列の中の要素の数 ////////////////////////////////////////////////// FUNCTION arrayPush(var arr[], str) DIM res = RESIZE(arr, UBound(arr) + 1) arr[res] = str RESULT = res + 1 FEND ////////////////////////////////////////////////// // 【引数】 // var arr[] : シャッフルする配列(参照引数) // 【戻値】 // ////////////////////////////////////////////////// PROCEDURE FisherYates(var arr[]) FOR n = UBound(arr) TO 0 STEP -1 DIM num = RANDOM(n+1) DIM tmp = arr[n] arr[n] = arr[num] arr[num] = tmp NEXT FEND ////////////////////////////////////////////////// // 【引数】 // expr : 評価する式 // truepart : 評価した式がTrueのときに返す値 // falsepart : 評価した式がFalseのときに返す値 // 【戻値】 // truepart : 評価した式がTrueのとき、falsepart : 評価した式がFalseのとき ////////////////////////////////////////////////// FUNCTION IIF(expr, truepart, falsepart) IFB EVAL(expr) THEN RESULT = truepart ELSE RESULT = falsepart ENDIF FEND ////////////////////////////////////////////////// // 【引数】 // 配列 : 上限値を求める配列 // 【戻値】 // 配列の上限値 ////////////////////////////////////////////////// FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND
結果
♦12 12
♠1 1
正解
----------
♠1 1
♥7 7
正解
----------
♥7 7
♥13 13
正解
----------
♥13 13
♦9 9
正解
----------
♦9 9
♥1 1
正解
----------
♥1 1
♥5 5
正解
----------
♥5 5
♥10 10
正解
----------
♥10 10
♣4 4
正解
----------
♣4 4
♠10 10
正解
----------
♠10 10
♥6 6
不正解

指定されたサービスを開始および停止できるかどうかを返す

DIM Shell = CREATEOLEOBJ("Shell.Application") DIM arr = SPLIT(DOSCMD("sc query state=all | findstr /i service_name"), "<#CR>") arr = strReplace("SERVICE_NAME: ", "", arr) FOR n = 0 TO UBound(arr) PRINT arr[n] + "<#TAB>" + Shell.CanStartStopService(arr[n]) NEXT ////////////////////////////////////////////////// // 【引数】 // search : 探したい値 // replace : 見つかった search を置き換える値 // subject : 検索・置換の対象となる文字列あるいは配列 // 【戻値】 // 置換後の文字列あるいは配列 ////////////////////////////////////////////////// FUNCTION strReplace(search, replace, subject) SELECT VARTYPE(subject) AND $2000 CASE $2000 // 配列 FOR n = 0 TO UBound(subject) subject[n] = REPLACE(subject[n], search, replace) NEXT RESULT = SLICE(subject) DEFAULT // 配列以外 RESULT = REPLACE(subject, search, replace) SELEND FEND ////////////////////////////////////////////////// // 【引数】 // 配列 : 上限値を求める配列 // 【戻値】 // 配列の上限値 ////////////////////////////////////////////////// FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND
結果
AdobeARMservice False
AJRouter False
ALG False
ALUpdateService False
AppHostSvc False
AppIDSvc False
Appinfo False
AppReadiness False
AppXSvc False
aspnet_state False
AudioEndpointBuilder False
Audiosrv False
autotimesvc False
AxInstSV False
BDESVC False
BFE False
BITS False
BrokerInfrastructure False
BTAGService False
BthAvctpSvc False
bthserv False
camsvc False
CDPSvc False
CertPropSvc False
CLHNService False
ClipSVC False
COMSysApp False
CoreMessagingRegistrar False
cphs False
CryptSvc False
CypherGuard cguard Service 32bit Edition False
CypherGuard cguard Service 64bit Edition False
CypherGuard Info Service False
dbupdate False
dbupdatem False
DbxSvc False
DcomLaunch False
defragsvc False
DeviceAssociationService False
DeviceInstall False
DevQueryBroker False
Dhcp False
diagnosticshub.standardcollector.service False
diagsvc False
DiagTrack False
DispBrokerDesktopSvc False
DisplayEnhancementService False
DmEnrollmentSvc False
dmwappushservice False
Dnscache False
DoSvc False
dot3svc False
DPS False
DsmSvc False
DsSvc False
DusmSvc False
Eaphost False
EFS False
embeddedmode False
EntAppSvc False
EventLog False
EventSystem False
Everything False
Fax False
fdPHost False
FDResPub False
fhsvc False
FontCache False
FontCache3.0.0.0 False
FrameServer False
Freemake Improver False
FreemakeVideoCapture False
GoogleChromeElevationService False
GoogleIMEJaCacheService False
gpsvc False
GraphicsPerfSvc False
gupdate False
gupdatem False
hidserv False
HvHost False
icssvc False
IDriverT False
IKEEXT False
ImeDictUpdateService False
InstallService False
iphlpsvc False
IpxlatCfgSvc False
KeyIso False
KtmRm False
LanmanServer False
LanmanWorkstation False
lfsvc False
LicenseManager False
LLHDClient False
LLHDCloader False
lltdsvc False
lmhosts False
LMS False
LSM False
LxpSvc False
MapsBroker False
MixedRealityOpenXRSvc False
MozillaMaintenance False
mpssvc False
MSDTC False
MSiSCSI False
msiserver False
MSMQ False
MSSQL$SQLEXPRESS False
MSSQLServerADHelper100 False
NaturalAuthentication False
NcaSvc False
NcbService False
NcdAutoSetup False
Netlogon False
Netman False
NetMsmqActivator False
NetPipeActivator False
netprofm False
NetSetupSvc False
NetTcpActivator False
NetTcpPortSharing False
NgcCtnrSvc False
NgcSvc False
NielsenUpdate True
NlaSvc False
nsi False
nurago InstallUpdate False
nurago NetworkMeter False
nurago Reporting Service False
ose64 False
osppsvc False
p2pimsvc False
p2psvc False
PBExtractService False
PcaSvc False
perceptionsimulation False
PerfHost False
PhoneSvc False
pla False
PlugPlay False
PNRPAutoReg False
PNRPsvc False
PolicyAgent False
Power False
PrintNotify False
ProfSvc False
PushToInstall False
QWAVE False
RasAuto False
RasMan False
RemoteAccess False
RemoteRegistry False
RetailDemo False
RmSvc False
RpcEptMapper False
RpcLocator False
RpcSs False
SamSs False
SCardSvr False
ScDeviceEnum False
Schedule False
SCPolicySvc False
SDRSVC False
seclogon False
SecurityHealthService False
SEMgrSvc False
SENS False
SensorDataService False
SensorService False
SensrSvc False
SessionEnv False
SgrmBroker False
SharedAccess False
SharedRealitySvc False
ShellHWDetection False
shpamsvc False
smphost False
SmsRouter False
SNMPTRAP False
spectrum False
Spooler False
sppsvc False
SQLAgent$SQLEXPRESS False
SQLBrowser False
SQLWriter False
SSDPSRV False
ssh-agent False
SstpSvc False
StateRepository False
stisvc False
StorSvc False
svsvc False
swprv False
SynTPEnhService False
SysMain False
SystemEventsBroker False
SystemExplorerHelpService False
TabletInputService False
TapiSrv False
TeamViewer False
TermService False
Themes False
TieringEngineService False
TimeBrokerSvc False
TMachInfo False
TODDSrv False
TokenBroker False
TosCoSrv False
TOSHIBA eco Utility Service False
TOSHIBA HDD SSD Alert Service False
TosRzTfSvc False
TPCHKarteSVC False
TPCHSrv False
TrkWks False
TroubleshootingSvc False
TrustedInstaller False
tzautoupdate False
UmRdpService False
UNS False
upnphost False
UserManager False
UsoSvc False
VacSvc False
VaultSvc False
vds False
vmicguestinterface False
vmicheartbeat False
vmickvpexchange False
vmicrdv False
vmicshutdown False
vmictimesync False
vmicvmsession False
vmicvss False
VSS False
VSStandardCollectorService150 False
W32Time False
w3logsvc False
W3SVC False
WaaSMedicSvc False
WalletService False
WarpJITSvc False
WAS False
wbengine False
WbioSrvc False
Wcmsvc False
wcncsvc False
WdiServiceHost False
WdiSystemHost False
WdNisSvc False
WebClient False
Wecsvc False
WEPHOSTSVC False
wercplsupport False
WerSvc False
WFDSConMgrSvc False
WiaRpc False
WinDefend False
WinHttpAutoProxySvc False
Winmgmt False
WinRM False
wisvc False
WlanSvc False
wlidsvc False
wlpasvc False
WManSvc False
wmiApSrv False
WMPNetworkSvc False
workfolderssvc False
WpcMonSvc False
WPDBusEnum False
WpnService False
wscsvc False
WSearch False
wuauserv False
WwanSvc False
XblAuthManager False
XblGameSave False
XboxGipSvc False
XboxNetApiSvc False
AarSvc_64da0 False
BcastDVRUserService_64da0 False
BluetoothUserService_64da0 False
CaptureService_64da0 False
cbdhsvc_64da0 False
CDPUserSvc_64da0 False
ConsentUxUserSvc_64da0 False
CredentialEnrollmentManagerUserSvc_64da0 False
DeviceAssociationBrokerSvc_64da0 False
DevicePickerUserSvc_64da0 False
DevicesFlowUserSvc_64da0 False
MessagingService_64da0 False
OneSyncSvc_64da0 False
PimIndexMaintenanceSvc_64da0 False
PrintWorkflowUserSvc_64da0 False
UnistoreSvc_64da0 False
UserDataSvc_64da0 False
WpnUserService_64da0 False