Batch 87 Array Index
Key Takeaways
The video demonstrates how to create a batch script called "array index" that returns the index or position of a value inside an array, with optional parameters for the array name, find string, return variable, and position.
Full Transcript
hey what's up guys rudolph here coming back at you with another batch tutorial and you know we've been looking at a race just recently and we're going to keep doing that right now keep pounding the pressure on the arrays and making some pretty cool programming stuff programs that's that's the word that i wanted to say but i was so excited i didn't even end up saying it yeah westside you know all right so uh let's get cmd ready to rock because i know i'm ready to rock i don't know about you guys but i'm pumped i'm excited we're just done the batch tutorials that's awesome okay let's go ahead and save this as add echo off no let's not let's call it array what is it what is it what do i want to call this what should i call this array index yeah i think it's array index array index.bat perfect now what array index will do or does or is going to do whatever you'd like however you'd like to say it will return the index or the position where we find um one value inside of the array so we'll need the array uh name itself we'll we'll need what we're trying to find we'll need to return and then of course we will need a position because we want to be able to make it optional or at least we want to make it decide whether or not we should start from a certain position or just go from the beginning so we're going to want to start by actually getting the the find string create string fine that can equal the second argument that we passed with because that's what it is and set position position is actually going to equal the fourth argument but we're immediately going to test right after it if the value of the position if that's equal to nothing so if they haven't actually passed anything in for the position then position can equal zero and if not then we don't have to worry about it but we also are going to want to set our return variable to equal negative one by default so on the off chance we don't find anything we can go ahead and just like say yeah we don't know where it is man go away come back another time and that's all there is to it but we are going to need a limit because we're going to be looping of course so we'll say the length of our array subtract one and then we'll begin the loop so four dash l g in now remember we're going to start from a certain position it's usually by default zero but of course we can modify that we'll increment by one and we'll go up until our limit then we'll do and we can go ahead and test with the conditional statement if the current position that we're at inside of the array if that's equal to what we're looking for or our find thing you know our variable here what we can actually do is go ahead and set our return statement or our return value to equal the current position and then we'll break out of the loop so we'll go to the end and we can go ahead and create end right down at the bottom here and we should be set to go alright let's go ahead and test this out if i were to create a script this is just a typical you know normal script we're working in every day i'll create my main function as usual local okay let's go ahead and create an array i think i'll say um array i think i'll have it say i am really hungry because you know i'm pretty hungry right now it's almost dinner time though i'm out getting pizza pretty soon that's cool all right now we're going to go ahead and call all right index pass in the array and let's say we're looking for i and the return can equal return we can echo out return now let's run our script oh and we had a problem what's going on here create string find uh oh it looks like it's probably over here yep yeah okay i forgot a limiter here sorry about that guys make sure you use a space or whatever you'd like to use and we can go ahead and say script and uh zero because it does not find it anywhere in fact i'm just kidding zero is the first position inside of our array remember because our computer starts counting array indexes at zero and then goes up you know zero one two three four that sort of thing so when we get zero that means it really is at position zero now if i was looking for am we get it at one what if i were looking for hungry that's a three and if we were to look for let's say food ah what do we get here negative one so it's not actually inside the script it's not inside the array anyway but there you go guys it's very simple very easy i'm sorry about the mess-ups there really it's not that big of a deal just uh just go make something now that's gonna find nothing because you know it's not gonna find anything that's that's as simple as it gets guys thank you very much though and i will see you in the next tutorial before i go though let's go actually go ahead and put this inside of our system path so array index we can go ahead and copy that and put it into our tools and i'll cut it and go ahead and put it into our system path see windows system 32 plop it right in there and we're ready to rock okay thank you very much guys uh please like the video if you enjoyed it please leave a comment if you would like to share some input and feedback that'd be really fantastic i'd love to know what you're thinking and maybe subscribe i don't know it's whatever you guys do but uh thanks again bye
Original Description
If you would like to support me, please like, comment & subscribe, and check me out on Patreon: https://patreon.com/johnhammond010
E-mail: johnhammond010@gmail.com
PayPal: http://paypal.me/johnhammond010
GitHub: https://github.com/JohnHammond
Site: http://www.johnhammond.org
Twitter: https://twitter.com/_johnhammond
Playlist
Uploads from John Hammond · John Hammond · 13 of 60
1
2
3
4
5
6
7
8
9
10
11
12
▶
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Code Commentaries? PHP to JavaScript in Bash and PHP!
John Hammond
Tutorials? MySQL connection with PHP and Bash!
John Hammond
Variable Naming in Python! Happy Birthday, Linux! Nokia N900!
John Hammond
JavaScript Splits The URL!
John Hammond
HTML Tables in Python!
John Hammond
HTML, Net Shares, GML!
John Hammond
Python 08 Programming Style and Comments
John Hammond
Python 26 Object Oriented Programming
John Hammond
75 Python Tutorials, Out Now!
John Hammond
Batch 14 Mathematical Expressions
John Hammond
Batch 85 Array Append
John Hammond
Batch 86 Array Count
John Hammond
Batch 87 Array Index
John Hammond
Batch 88 Array Insert
John Hammond
Batch 89 Array Remove
John Hammond
Batch 90 Array Reverse
John Hammond
Python [colorama] 00 Installing on Linux
John Hammond
Python [colorama] 09 Cursor Position
John Hammond
Python [hashlib] 02 Algorithms
John Hammond
Python 00 Installing IDLE on Linux
John Hammond
Python [pygame] 11 Rectangular Collision Detection
John Hammond
Python [pygame] 12 Platforming Rectangular Collision Resolution
John Hammond
Python [XML-RPC] 01 Research
John Hammond
Python [pyenchant] 03 Personal Word Lists
John Hammond
FancyURLopener Authentication and User-Agent [urllib] 03
John Hammond
Python 04: PEP8 Coding
John Hammond
Python Challenge! 17 COOKIES
John Hammond
Google CTF 2016: Ernst Echidna
John Hammond
Google CTF 2016: Spotted Quoll
John Hammond
Google CTF 2016: Can you Repo It?
John Hammond
Google CTF 2016: No Big Deal
John Hammond
Google CTF 2016: In Recorded Conversation
John Hammond
Homemade CTF Challenge: 01 "Orchestra"
John Hammond
Homemade CTF Challenge: 02 "Bae's Base"
John Hammond
Homemade CTF Challenge: 03 "Web Hunt"
John Hammond
Homemade CTF Challenge: 04 "UPX"
John Hammond
Homemade CTF Challenge: 05 "The Assumption Song"
John Hammond
Homemade CTF Challenge: 06 "A Brisk Stroll"
John Hammond
Homemade CTF Challenge: 06 "I lost my password!"
John Hammond
web25 :: Mr. Robot : EKOPARTY CTF 2016
John Hammond
web50 : RFC 7230 :: EKOPARTY CTF 2016
John Hammond
misc50 : Hidden inside EKO :: EKOPARTY CTF 2016
John Hammond
Hack The Vote 2016 CTF: Sander's Fan Club [web100]
John Hammond
Hack The Vote 2016 CTF Warpspeed [forensics150]
John Hammond
Juniors CTF 2016 :: Black Suprematic Square
John Hammond
Juniors CTF 2016 :: Six Strange Tales
John Hammond
Juniors CTF 2016 :: Lost Code
John Hammond
Juniors CTF 2016 :: Here Goes!
John Hammond
Juniors CTF 2016 :: Southern Cross
John Hammond
Juniors CTF 2016 :: Clone Attack
John Hammond
Juniors CTF 2016 :: Dirty Repo
John Hammond
Juniors CTF 2016 :: Hackers Blog
John Hammond
Juniors CTF 2016 :: Voting!!!
John Hammond
Juniors CTF 2016 :: The Good, The Bad and The Junkman
John Hammond
Juniors CTF 2016 :: Stop Thief!
John Hammond
Juniors CTF 2016 :: ROFL
John Hammond
Juniors CTF 2016 :: Restriced Area
John Hammond
Juniors CTF 2016 :: Oh SSH!
John Hammond
HackCon CTF 2017 TRIVIA and BONUS Challenges
John Hammond
HackCon CTF 2017 "Bacche" Challenges
John Hammond
Related Reads
📰
📰
📰
📰
CTF Day 53 | bytemancy 2 | General Skills
Medium · Cybersecurity
That CAPTCHA Is Not a Bot Control. Here Is How to Prove It in a Report.
Medium · Cybersecurity
Windows Privilege Escalation — TryHackMe Walkthrough
Medium · Cybersecurity
Still paying 4 years for a tech career?
Medium · Cybersecurity
🎓
Tutor Explanation
DeepCamp AI