Batch 88 Array Insert
Key Takeaways
Demonstrates inserting an element into an array
Full Transcript
hey what is going on guys RL here coming back at you with another batch tutorial all right it's 5 o'clock in the morning I'm a little tired but hey we're going to push this batch tutorial right out of the way and move on for the next one because today we're working with some more arrays now in the last couple of videos we've been working with arrays we've been appending values on there we've been counting to get see how many occurrences of one index are in the array that sort of thing but now we're going to actually go ahead and try and insert a value into an array at a certain position when what this will do is it will open overwrite um the current value at any certain position just shift everything to the right of it actually farther to the right so it'll increase the length and that sort of thing it'll um modify the new the the initial array and um it's actually doing this by just sort of like recreating it it's updating it by gathering what you had in the array to begin with adding the new piece in as a string and then just passing that right back into the create array function and just sort of overwriting it so it's a little it's a little strange it's a little awkward but you know it's okay it's one way to do it and I guess that's all that matters so I'm going to go ahead and call mine array insert. bat so I'll save that it could be add Echo off and the syntax is going of course be array insert with the array name we'll need to pass in the delimiter we'll need to pass in the value that we're going to update with and we're going to actually put in a position as well now we don't have to have a return type because it's actually going to modify the array but um I guess that's really all we have to worry about and actually we're going to need to create some strings so value is the third argument that we passed to it and the limiter is important too so limiter that's number two okay and the position that's our fourth argument and now we need to actually set up a new array value or like a string that's going to actually keep track of the new array and then we'll begin to Loop so we're going to need a limit the limit can equal the value of our array length so we're using percent sign one as our array remember and then the length afterward it's just getting the length and we'll subtract one from it and then we'll start to Loop so four- l g in 01 limit and here all we really do is some tests so if the current position is actually equal to the position that we're going going to be adding this new value in what we're going to actually do is set the new array to equal what we have of the new array so far with the value in it along with the delimiter so that works well for us and actually what we need to be doing right after that is always adding on the previous values so we still have to test if the current position is equal to the Limit because if it is then we don't want to add the the delimiter back onto it but we still want to have everything else so we can go ahead and set new array to equal the value of new array so far actually our what we have so far inside the array so the current position inside the array and we will be doing this for the other if it's not the end of the array we'll just have the delimiter tacked on to the end of it all right and then at the very end we're done looping through it all we can go ahead and call create array with our array name String form of the delimiter and the value of our new array all right now let's go ahead and um oh create a new script to actually work with this I can do add Echo off set local all right now what we can do is go ahead and call create array I'll call my array and I'll have a space be my variable at least our delimiter here and it says I am really tired how about that and then we'll go ahead and call array insert and we'll insert into array with our delimiter and I want to say not and that can be position let's say I want I am now I want it to overwrite this one here so I am not really tired how about that so it would actually be two that we're going to be overwriting so let's try this in CMD I'll drag it down you guys script and we'll obviously want to Echo out our array it says I am not really tired and we can Echo out the array length and that's five now because there are five words in it we go out array two and it says not and everything else is still accessible so this works well for us but what if I actually tried to put it in at 04 the last position Echo right I am really tired now if I put it in three I am really not tired so it won't put it in the end because we're not appending anything to it so if I actually Echo out array length this will still work at five because there are five characters in it but if you it won't actually insert at the end you have to use array a pen for that so it'll only insert to overwrite any other value that is not at the end and that sort of thing but uh there you go guys that's how it works that's how we can manipulate it um it's just simple like reconstructing the array as needed so I'm going to go ahead and put this inside of my system path and wow Explorer is ginormous all right all right insert we can put it in our tools we'll put it in um see Windows system 32 plop it right in there and uh we're all done all right thank you very much for watching guys hope you enjoyed this and I'll see you in the next tutorial 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
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from John Hammond · John Hammond · 14 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
▶
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
📰
📰
📰
📰
Fool’s Mate (TryHackMe): I Checkmated the Bot, the Server Still Said No — So I Polluted Its…
Medium · Cybersecurity
This Free Tool Showed Me A Company’s Deleted API Keys From 2019
Medium · Cybersecurity
I Found 400 Hidden Subdomains On My First Target Using One Free Tool
Medium · Cybersecurity
Crypto Market Faces Security Risks Amidst Growing Adoption and Innovation
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI