Author Topic: QB64SOURCECODE.COM  (Read 17518 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #30 on: April 22, 2020, 11:46:24 pm »
I'm almost finished with Task #12 - just creating a "Your Turn" program.

I updated Tasks 3 - 11 to include a "Contents" section at the top for easy navigation throughout the pages. The remainder of the tasks will have this as well.

@TempodiBasic REDIM _PRESERVE works with one dimensional arrays. I'll add a note in the task that it will not with mutli-dimensional arrays. Also, not sure what you mean by "about the tip of null string found by INSTR (chapter 11) in any string".
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #31 on: April 22, 2020, 11:57:58 pm »
Terry - Search the site is what I meant - aka Wiki on Steroids
        - Pete's String Math. Finding some useful uses as it's more forgiving if I didn't DIM the variable correctly or math routine takes the result into Sc Note. Also a little handier with _PrintString
           then covering numeric to string and _Printstring. But I'm unsure of how to get the most out of it.

Well I can barely code basic HTML so a search feature may be a ways off. I did however add a contents section to the top of each page that will help in jumping to specific sections of each task. I'll probably create a jump page with all the commands that are covered in the tutorial so you'll be able to jump to a task and straight to that section. That would be something I work on after I've finished the tasks. The farther I get into these things the longer and more complicated they get. My goal is to have them finished by the end of May at the latest.
In order to understand recursion, one must first understand recursion.

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #32 on: April 23, 2020, 03:52:35 am »
As for searching, you might find Google's Custom Search useful: https://cse.google.com/cse/all

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #33 on: April 23, 2020, 10:01:16 am »
Thanks Luke, I'll look into that.
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #34 on: April 23, 2020, 12:24:34 pm »
Task 12 has been added. The "Your Turn" section for it has nothing yet however. Having a mental block trying to think of a simple program for someone to write for this task. It'll come to me in a few days I'm sure. On to Task 13.
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #35 on: April 23, 2020, 03:23:18 pm »
Task 12 has been added. The "Your Turn" section for it has nothing yet however. Having a mental block trying to think of a simple program for someone to write for this task. It'll come to me in a few days I'm sure. On to Task 13.

An analog clock, a calculator, a simple Eval Function (without parenthesis), drawing regular n-gon polygons, ordering pizza creating pizza numbers determined whether to add one of 8 topping becomes a binary number and could be translated to base 10 number, ie onions, mushrooms, pepperoni, sausage:  yes to onions and sausage is 1001 a number 9 pizza or yes to mushrooms and pepperoni is a 0110 = a number 6 pizza, onions and pepperoni 1010 = number 10...

Maybe not just one program? maybe the snippets part that employs math function. Oh also Metric conversion programs.

Wait... nothing about number bases? Binary, Octal, Hexadecimal? That would go well with bit math.
« Last Edit: April 23, 2020, 03:32:53 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #36 on: April 23, 2020, 06:35:54 pm »
Hi Terry
about
Quote
Also, not sure what you mean by "about the tip of null string found by INSTR (chapter 11) in any string".
nothing else that INSTR returns 1 if you seach a nullstring  like this s$="" in any kind of string...
this becomes important when you use INSTR to evaluate a keyboard input INKEY$ returns "" if no key is pressed, INPUT and INPUT$(1) return "" if we press only Enter key without nothing typed before Enter. and this code wants stress this idea
Code: QB64: [Select]
  1.     '-------------------------------
  2.     ' Variable Declaration Section -
  3.     '-------------------------------
  4.      
  5.     DIM Answer$
  6.      
  7.     '--------------------------
  8.     ' Main Program Begins Here-
  9.     '--------------------------
  10.     Again:
  11.     PRINT "Press only Enter key to see the tip"
  12.     INPUT "Do you play again ?(Y/N)", Answer$
  13.     PRINT INSTR("Y", UCASE$(Answer$))
  14.     IF INSTR("Y", UCASE$(Answer$)) GOTO Again ELSE PRINT "Goodbye"
If you think that this kind of information can be useful to explain how INSTR works you can add to your work.

Thanks to read
« Last Edit: April 24, 2020, 12:51:46 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #37 on: April 23, 2020, 07:13:42 pm »
TempodiBasic talking about this?
Code: QB64: [Select]
  1. print instr("abcd", "")  'outputs 1
  2.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #38 on: April 24, 2020, 12:55:30 pm »
just right Bplus!
It is a feature of INSTR that has wasted my time so many times because it makes an hole in the control of flow when related to a string of input.
Thanks to let be clearer my comunication!
Programming isn't difficult, only it's  consuming time and coffee

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #39 on: April 24, 2020, 01:50:55 pm »
TempodiBasic talking about this?
Code: QB64: [Select]
  1. print instr("abcd", "")  'outputs 1
  2.  

Well, I'm not sure if this is a bug or not. Technically a null string "" is contained in every string. I will add this oddity to the INSTR section in the tutorial though to let others know this situation exists. Thanks for bringing it to my attention TempodiBasic.
In order to understand recursion, one must first understand recursion.

FellippeHeitor

  • Guest
Re: QB64SOURCECODE.COM
« Reply #40 on: April 24, 2020, 02:29:03 pm »
Not a bug.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: QB64SOURCECODE.COM
« Reply #41 on: April 24, 2020, 02:41:45 pm »
I posted about that, what, maybe on the .Net site? I had an instance in a data reading program where I mistakenly had a null entry. When it went through my instr() routine, yep, I get this weird unexpected error, so I looked at the code, tested it out, and sure enough, discovered that INSTR() treats nothing as something. Since that experience, I often code...

Code: QB64: [Select]
  1. LINE INPUT #1, a$
  2. IF INSTR("Pete", a$) AND a$ <> "" THEN
  3. PRINT "We Found Pete!"
  4.  

Note: You cannot rely on using IF LEN(a$), because of how AND treats two numbers. A return of 1 AND 1 would be true, but a return of 1 AND 2 would be false. For instance, this would NOT work...

Code: QB64: [Select]
  1. a$ = "Pete"
  2. IF INSTR("Pete", a$) AND LEN(a$) THEN
  3.     PRINT "We Found Pete with LEN() added!"
  4.     PRINT "We didn't find Pete with LEN() added!"

Pete

PS And as Fell mentioned, it's not a bug. It was this way in QB45, too.
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64SOURCECODE.COM
« Reply #42 on: April 24, 2020, 02:42:53 pm »
Well, I'm not sure if this is a bug or not. Technically a null string "" is contained in every string. I will add this oddity to the INSTR section in the tutorial though to let others know this situation exists. Thanks for bringing it to my attention TempodiBasic.

Think of it like this:

a$ = ""
b$ = "abcd"
c$ = a$ + b$
PRINT INSTR(c$, a$)

Now, you just put a$ to the front of c$.  It's in there, honest!  So why would you print 0 as the result and say it's not there??
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64SOURCECODE.COM
« Reply #43 on: April 24, 2020, 02:45:57 pm »
IF INSTR("Pete", a$) AND LEN(a$) THEN

The above is binary math, not logical conditions.  Change it to the following:

IF INSTR("Pete", a$) <> 0 AND LEN(a$) <> 0 THEN
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: QB64SOURCECODE.COM
« Reply #44 on: April 24, 2020, 02:55:47 pm »
Also, since neither is ever gonna return a negative, it's enough to:

Code: QB64: [Select]
  1. IF INSTR("Pete", a$) > 0 AND LEN(a$) > 0 THEN