Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use arrays in BAT batch processing

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use arrays in BAT batch processing, which is very detailed and has a certain reference value. Friends who are interested must read it!

There is no native support for arrays in batch instructions, but that doesn't mean it can't be simulated.

Take a look at the following code:

SET Obj_Length=2 SET Obj [0] .name = Test1SET Obj [0] .value = Hello World SET Obj [1] .name = Test2SET Obj [1] .value = blahblah

This defines an array, and it is an array of structures.

When you need a value, you can play like this:

SET Obj_Index=0: LoopStartIF% Obj_Index% EQU% Obj_Length% GOTO: EOF SET Obj_Current.Name=0SET Obj_Current.Value=0 FOR / F "usebackq delims==. tokens=1-3"% I IN (`SET Obj [% Obj_Index%] `) DO (SET Obj_Current.%%J=%%K) ECHO Name=% Obj_Current.Name%ECHO Value=% Obj_Current.Value%ECHO. SET / An Obj_Index=%Obj_Index% + 1 GOTO LoopStart

Output result:

Name = Test1Value = Hello WorldName = Test2Value = blahblah above is all the content of the article "how to use arrays in BAT batches". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report