Page 1 of 3
MULTIPLICATON OF A FIELD IN A FILE WITH A CONSTANT
Posted: Wed Sep 14, 2005 2:59 pm
by GMCM
I HAVE ONLY USED QUICK BASIC 4.5 IN VERY BASIC WAYS. MAINLY FOR DATA MANIPULATION. WHAT I NEED TO DO IS MULTIPLY A FIELD FROM A TEXT FILE WITH A CONSTANT. FOR EXAMPLE MID$(LINE$, 79, 8)TIMES .9 AND SHOW THAT RESULT IN MY OUTPUT FILE. I KNOW HOW TO SHOW THE RESULT IN MY OUTPUT FILE, IT'S JUST THE CALCULATION I AM HAVING PROBLEMS WITH. JUST NOT SURE HOW TO DO THIS. ALSO SOME RESULTS NEED TO HAVE 2 DECIMAL PLACES WHILE OTHERS NEED TO HAVE 4 DECIMAL PLACES.
THANKS.
Posted: Wed Sep 14, 2005 3:12 pm
by Kyle
Try these:

Posted: Wed Sep 14, 2005 5:13 pm
by {Nathan}
all i saw was the caps, and now im saying screw you, noobie hippie. pay attn in school.
Posted: Wed Sep 14, 2005 8:57 pm
by moneo
Hey guys, be nice to this new guy. He has a legitimate question.
GMCM:
1) Can the number you get from MID$(LINE$, 79, 8) have a decimal point? Just in case it does, do this:
DIM IPNUM AS DOUBLE
IPNUM=VAL(MID$(LINE$,79,8))
2) Just to be consistent, and have all your variables as DOUBLE do this also:
DIM CONPT9 AS DOUBLE
CONPT9=.9
3) Then, you multiply as follows:
DIM PRODUCT AS DOUBLE
PRODUCT=IPNUM*CONPT9
4) Note that all the DIM statements should actually appear at the top of the code.
5) The PRODUCT will contain as many decimal places as the numbers determine. If the IPNUM had 2 decimals, then 2 + 1 of the .9 can give you a maximum of 3 decimal places in the PRODUCT.
6) You can use PRINT #n USING to control how many maximum decimal places you need in your result to the output file. If for some reason you're not gonna use the PRINT USING, then you will need some extra code to normalize the result before writing it to the output file. Tell us what you're going to do.
*****
Posted: Thu Sep 15, 2005 5:00 am
by Z!re
WE'RE SORRY WE THINK YOU'RE STUPID, BUT TYPING IN ALL CAPS KIND OF GIVES THAT IMPRESSION!
Posted: Thu Sep 15, 2005 6:39 am
by Seb McClouth
Z!re wrote:WE'RE SORRY WE THINK YOU'RE STUPID, BUT TYPING IN ALL CAPS KIND OF GIVES THAT IMPRESSION!
I'd like to add something to Z!re's post: (not intended for Z!re) WE'RE NOT DEAF!!!
Posted: Thu Sep 15, 2005 12:59 pm
by moneo
Z!re and Seb,
Please be a little more tolerant. You're right, by today's standards typing in all caps, or solid caps, is now pass?.
But you should consider that many of us oldtimers used systems, and wrote programs, when there was only 6-bit BCD codes which did not have any lowercase characters. If you used BCD for many years, you got in the habit of typing with all caps even after 7 and 8 bit ASCII became of common usage. I myself still coded programs in all caps until about 1992, when I noticed that the other programmers on a project were using lowercase, and that this code looked much better.
The same was true for electronic mail systems before Internet email, like General Electric's Worldcom mail system in 1969-1970, and Citibank's Citimail system in 1973 through the 1980's. Messages were typed in all caps, and you got into the habit.
One more point. In Spanish-speaking countries, many people still type emails today in all caps. The reason for this is that by using all caps they don't have to worry about putting accents and other diacritical marks on the Spanish words, which is time-consuming and truly a pain in the neck. Using all caps becomes a habit, and most of these people also use them when writing emails in English.
*****
Posted: Thu Sep 15, 2005 2:27 pm
by Z!re
It's called progress.
You dont see me running around nude, do you? We "evolved" past that.. just like we evolved past ALL UPPERCASE TYPING.
EDIT:
moneo wrote:5) The PRODUCT will contain as many decimal places as the numbers determine. If the IPNUM had 2 decimals, then 2 + 1 of the .9 can give you a maximum of 3 decimal places in the PRODUCT.
Code: Select all
DIM a AS DOUBLE
DIM b AS DOUBLE
DIM c AS DOUBLE
a = 1.1
b = 2.7
c = a / b
PRINT c

Posted: Thu Sep 15, 2005 9:25 pm
by Nodtveidt
Z!re wrote:You dont see me running around nude, do you?
What was that last night then?!?

Posted: Fri Sep 16, 2005 3:19 am
by Seb McClouth
Nekrophidius wrote:Z!re wrote:You dont see me running around nude, do you?
What was that last night then?!?

That's sumfin we call:
None of your business and not for your eyes
Caps or no caps that is the question... my answer: no caps... I'm tolerant but you would understand what's is like when ppl start swearing at you when your using a chatbox and you forget to turn of your Caps Lock...
grtz
Seb
Posted: Fri Sep 16, 2005 6:42 am
by Seb McClouth
Nekrophidius wrote:Seb McClouth wrote:Nekrophidius wrote:
What was that last night then?!?

That's sumfin we call:
None of your business and not for your eyes
Err...I wasn't talking to you...so stfu, eh?
Eey mate... don't tell me to stfu ever... I don't like that sh... crap...
grtz
Posted: Fri Sep 16, 2005 9:00 am
by Seb McClouth
Last words to you: act your age... until that time... my kind regards to you...
grtz
Seb
Posted: Fri Sep 16, 2005 1:22 pm
by SebMcClouth
Fine... have it your way...
Posted: Fri Sep 16, 2005 3:05 pm
by Z!re
*blows sodacan (aka: nekrophidius) a kiss*
Don't be so mean to the new people
And about last night nek.. I was drunk ok.. shame on you!
Posted: Fri Sep 16, 2005 4:34 pm
by Zamaster
Thats the funniest picture ever! Where'd you get it?
Posted: Fri Sep 16, 2005 4:44 pm
by {Nathan}
Seb McClouth wrote:Last words to you: act your age... until that time... my kind regards to you...
grtz
Seb
Ever heard Grow Up by Simple Plan?
Posted: Fri Sep 16, 2005 10:48 pm
by Michael Calkins
All caps does make text harder to read, but you would expect that MS-DOS programmers like us would be used to that. For example: file names in DOS are usually all caps, as are license agreements and some documentation for MS-DOS programs. All caps is no reason to flame, and absolutely not an indication of stupidity, anymore than all lowercase is.
Regards,
Michael
Long live MS-DOS! Long may it reign!! :-D
Posted: Fri Sep 16, 2005 11:02 pm
by moneo
Thanks for speaking up, Michael.
*****
Posted: Sat Sep 17, 2005 9:56 am
by Patz QuickBASIC Creations
I use this when I need to make a number have 4 decimal places.
Code: Select all
NumberTesting$ = STR$(Number)
IF NOT INSTR(".", NumberTesting$) THEN NumberTesting$ = NumberTesting$ + ".0000"
While LEN(NumberTesting$-INSTR(".", NumberTesting$) < 4
Let NumberTesting$ = NumberTesting$ + "0"
WEND
Posted: Sat Sep 17, 2005 12:17 pm
by moneo
PQBC wrote:I use this when I need to make a number have 4 decimal places.
Code: Select all
NumberTesting$ = STR$(Number)
IF NOT INSTR(".", NumberTesting$) THEN NumberTesting$ = NumberTesting + ".0000"
While LEN(NumberTesting)-INSTR(".", NumberTesting$) < 4
Let NumberTesting$ = NumberTesting$ + "0"
WEND
Other than the fact that you left the dollar sign off of NumberTesting$ twice, and that the code is a little verbose, it looks like it should get the job done.
*****