Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

A semi-advanced parts shopping list

Okay so yesterday in IT class we were building PC's. Instead of using excel (which i hate) I decided to use something in batch like
Code
set /p part=
set /p cost =
echo %part% %cost% >>parts.txt

then I got extremely carried away and made this instead. It utilizes the 'type' command, to print the list in to another terminal which refreshes every two seconds or so.

Commands:
type 'listall' to list everything in the list without the price
type 'cls' to clear the list

^note you have to type it as the item name, then press enter twice for either of those to work.

You don't have to use it as a shopping list of course. I've got a few more project ideas that use the 'type' command in the same refreshing & %temp% methods used in this code. And since i'll probably never use this again after next week maybe someone here can.

code - https://pastebin.com/VBx6RyRU
(also note you can't use spaces for some reason)
[Image: dfc11c782476a629f5027d1ff8396131.gif]
I actually think this is an excellent exercise.

Perhaps you may find it useful to use
Code
for /f "tokens=*" %%a in (parts.txt) do echo %%a

If you wanted to pick out certain elements from your list, this would be the way to do it. I'm not sure if you're comfortable with enableDelayedExpansion (or for loops), but it would be incredibly useful to you as you could really spruce up this code! (Not that there is anything wrong with it)

If you need any help, just ask.
(May 2, 2018 07:02 PM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote:  I actually think this is an excellent exercise.

Perhaps you may find it useful to use
Code
for /f "tokens=*" %%a in (parts.txt) do echo %%a

If you wanted to pick out certain elements from your list, this would be the way to do it. I'm not sure if you're comfortable with enableDelayedExpansion (or for loops), but it would be incredibly useful to you as you could really spruce up this code! (Not that there is anything wrong with it)

If you need any help, just ask.

Haha yeah thanks bro. I actually did think the
Code
for tokens
thing would've come in handy but i have absolutely no idea how to use it :(
(May 2, 2018 07:11 PM)Sir-Teabag Wrote:  -snip-

This is a 4 line bit of code that will help you understand

Code
@echo off

rem Ever heard of a delimiter?
rem A delimiter (in this case it's a space by default) will tell
rem the loop to loop through both elements in the string instead of
rem just the string itself.
set "stringWithSpaces=Hello World"

for /f "tokens=1,2" %%a in ("%stringWithSpaces%") do (
    rem %%a is the first element separated by the space "Hello"
    echo %%a
    rem %%b is the second element separated by the space "World"
    echo %%b
)
pause
(May 2, 2018 08:19 PM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote:  This is a 4 line bit of code that will help you understand

Code
@echo off

rem Ever heard of a delimiter?
rem A delimiter (in this case it's a space by default) will tell
rem the loop to loop through both elements in the string instead of
rem just the string itself.
set "stringWithSpaces=Hello World"

for /f "tokens=1,2" %%a in ("%stringWithSpaces%") do (
rem %%a is the first element separated by the space "Hello"
echo %%a
rem %%b is the second element separated by the space "World"
echo %%b
)
pause

Hmm I think that makes sense..
Do you know any in-depth guides to this command?

Cheers :D
That's a very cool script @Sir-Teabag!
(May 3, 2018 01:07 AM)Sir-Teabag Wrote:  Hmm I think that makes sense..
Do you know any in-depth guides to this command?

Cheers :D

Actually I do lol

https://hackforums.net/showthread.php?tid=3645708
(May 3, 2018 04:34 AM)ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ Wrote:  Actually I do lol

https://hackforums.net/showthread.php?tid=3645708

haha wow thank you very much! I'm sure this will come in handy soon


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Ineed2learn2eatJul 13, 2017 10:48 AM 3 228 Jul 13, 2017 10:48 AM
Last Post: Ineed2learn2eat
[Shell] by Minus0stDec 24, 2013 03:43 AM 15 283 Dec 24, 2013 03:43 AM
Last Post: ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™
[.NET] by iFruityNov 22, 2013 06:44 AM 4 286 Nov 22, 2013 06:44 AM
Last Post: SIM-1456245