Page 1 of 2

newbie question

Posted: 14 Jun 2011 19:48
by renzlo
how do you code in pure batch, a counter that will count characters in a text file?

is it using findstr through regular expressions?

kindly enlighten me.

Re: newbie question

Posted: 14 Jun 2011 20:24
by Cleptography
First you open a command prompt then you type in format c: then you learn a real programming language then you realize counting in batch is stupid then you go to your mirror you look into it and then you say to yourself I am a moron.
UNTESTED:
:shock:

Re: newbie question

Posted: 14 Jun 2011 20:29
by nitt
Cleptography wrote:First you open a command prompt then you type in format c: then you learn a real programming language then you realize counting in batch is stupid then you go to your mirror you look into it and then you say to yourself I am a moron.
UNTESTED:
:shock:


Don't be such a jerk.

Anyways, I'm not actually sure. I know each character is a byte, so checking the file size should work.

I do not know how to do this in Batch, so I can use a JavaScript TMP file to do the job for me.

Code: Select all

@echo off
set file=test.txt
echo var wmi = new ActiveXObject("scripting.filesystemobject");var file = wmi.getfile("%file%");WScript.Echo(file.Size); > ~tmp.js
for /f %%a in ('cscript "~tmp.js"') do (set size=%%a)
del ~tmp.js
echo %size%
pause


That will return the size of the file, which is better than just counting the characters because if the file isn't in ASCII it would give you an error.

Re: newbie question

Posted: 14 Jun 2011 20:55
by Cleptography
nitt wrote:Don't be such a jerk. Anyways, I'm not actually sure. I know each character is a byte, so checking the file size should work. I do not know how to do this in Batch, so I can use a JavaScript TMP file to do the job for me.

I will stop being a jerk when you stop being such an idiot.
Do you mean javascript or jscript :?: :shock:

Re: newbie question

Posted: 15 Jun 2011 01:21
by nitt
Cleptography wrote:
nitt wrote:Don't be such a jerk. Anyways, I'm not actually sure. I know each character is a byte, so checking the file size should work. I do not know how to do this in Batch, so I can use a JavaScript TMP file to do the job for me.

I will stop being a jerk when you stop being such an idiot.
Do you mean javascript or jscript :?: :shock:


だまれ。あなたはばかです!

JScript, JavaScript, who cares? They are basically the same, except one has more restrictions. And both of them can run this code.

Re: newbie question

Posted: 15 Jun 2011 01:36
by Cleptography
Hush nitt you are young and new still learning. Get your facts right.

Re: newbie question

Posted: 15 Jun 2011 01:41
by nitt
Cleptography wrote:Hush nitt you are young and new still learning. Get your facts right.


My facts are right you just are upset.

貴方は悪です!

Re: newbie question

Posted: 15 Jun 2011 02:41
by Cleptography
Why am I upset? I don't have anything to be upset about.

Re: newbie question

Posted: 15 Jun 2011 03:55
by orange_batch
あ。nittさんは日本語ができますね

できませんと思いますw

Re: newbie question

Posted: 15 Jun 2011 04:01
by renzlo
thanks nitt for the reply, i appreciate it. By the way, i can easily write a batch script that will get the byte size just by adding, ~z, but there's a huge difference between them. Like, what if i just want to count characters excluding spaces, i am just wondering if this could be done.

Re: newbie question

Posted: 15 Jun 2011 04:27
by Cleptography
I take it orange and nitt just discovered google translate? :roll:

Re: newbie question

Posted: 15 Jun 2011 04:41
by nitt
Cleptography wrote:I take it orange and nitt just discovered google translate? :roll:


No. Some people actually know some Japanese.

Re: newbie question

Posted: 15 Jun 2011 04:45
by Cleptography
Yeah and you are not one of them. You lie so bad child.
Shall we examine your dribble?
First you are using an English keyboard.
Second ! is not a Japanese character
Third When you enter that into google translate it translates it perfectly into English
Which anyone speaking any language outside of English will tell you when something
is spoken natively google translate mixes up words.
So, like I said lies lies lies.
It's a lot easier to act smart and get caught being dumb then it is to act dumb and get
caught being smart.

Re: newbie question

Posted: 15 Jun 2011 05:03
by nitt
Cleptography wrote:Yeah and you are not one of them. You lie so bad child.


Do I have to explain everything to you? You're such a troll.

あなたはばかです!

anata ha baka desu!

"Anata" means "you". "ha" can also be written as "wa", but when you are typing you have to write it as "ha". This is just a particle that really doesn't need to be explained for this sentence. Now everyone knows "baka" means "idiot", "stupid", or "fool", the I need to explain the "desu". "Desu" is pronounced "des", not "des-oo". It is a verb meaning "am", "is", or "are". And verbs in Japanese always come at the end of the sentence. This sentence would directly translate to "you stupid are". But due to their sentence structure, it is equivalent to "You are stupid", "You are a fool", or "You are an idiot".

Now for a more complex sentence we could talk about "I walk to the sky". I'm still new to using verbs, so this is not 100% accurate.

But "I" in Japanese can be many things. I tend to use "ore", because using "watashi" can make you sound like a chick. The verb for "walk" is "aruku". And the word for "sky" is "sora" (ever played Kingdom Hearts?). So we would be looking at something similar to
ore ni sora ga aruku

or

俺にそらが歩く。

Like I said, don't trust me. I'm only new to verbs. Even though it translates correctly, you may sound like a scrub saying it. I'm not really sure, never got an professional opinion. I've been teaching myself by translating random sentences mostly.


Now more of a question sentence. Let's say, "What is this"?

This sentence would look more like "this what is?" in Japanese.

"Kore" means "this". "nan" means "what". And we already know the verb for "is". But we also have to note that for a question, we must end it with "ka".

kore wa nan desu ka

これは何ですか?

For a recap, another quick sentence I could show is "Are you Japanese?"

anata wa nihon-jin desu ka

"nihon" means "Japan" and "-jin" means "...person". Like "a Japan person". Or "Japanese".

あなたは日本人か?


Don't take me on for this. Like I've said, I've mostly been teaching myself so I really only get my confirmation from a cheap little translator.



First you are using an English keyboard.


Okay?

Second ! is not a Japanese character


So? Why can't I use that? They do.

Third When you enter that into google translate it translates it perfectly into English


Because I write it to the translator, 'cause I teach myself.

Which anyone speaking any language outside of English will tell you when something
is spoken natively google translate mixes up words.


Yes, so if I translated it with Google Translator it would NOT input correctly

I hope you know that computers in Japan are not programmed in Japanese, but in English. English is taught throughout school years and is required for students to learn. And computers in Japan use Roman keyboards, the same way I use mine. All (Windows) computers have something built in called Windows IME that is what is used. It is just not default in English computer, so you have to enable it yourself in Control Panel.

I'm a bit of a Japanophile. It's actually not hard. You just have to try.

I rest my case.

Re: newbie question

Posted: 15 Jun 2011 05:17
by orange_batch
Haha, you guys. I'm a total Japanophile and I started teaching myself Japanese in 2003. I typed that using Microsoft IME.

この常識非常識OHMYGOD