Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: Licentia on October 12, 2004, 08:02:23 PM



Title: Looking for a Command.
Post by: Licentia on October 12, 2004, 08:02:23 PM
I'm looking for a command.  It's the command for opening a string variable and dividing it into several variables.  I have looked yesterday and today through several tutorials for that command and i'm not finding it, nor can I find the website with the big Qbasic Advanced commands list.  It was an awesome list.

  Does anyone know the command I am refering to?  I think it starts with an M.  It's like mcg or something.  And does anyone know the website of that QBasic Advanced commands list?  It has the commands, and then you can click on most of them and then it gives instructions on how the command works.


Title: Looking for a Command.
Post by: Z!re on October 12, 2004, 08:11:45 PM
Code:
MID$()


Title: Looking for a Command.
Post by: Licentia on October 12, 2004, 08:39:39 PM
Quote from: "Z!re"
Code:
MID$()


  So easy to find info on a command when you know what the command is.  Thanks!


Title: Looking for a Command.
Post by: Crono on October 13, 2004, 06:24:11 AM
Here: http://forum.qbasicnews.com/viewtopic.php?t=6991

I hope its usefull to ya, kinda looks like the same question


Title: Re: Looking for a Command.
Post by: whitetiger0990 on October 13, 2004, 08:31:22 AM
Quote from: "Licentia"
And does anyone know the website of that QBasic Advanced commands list?  It has the commands, and then you can click on most of them and then it gives instructions on how the command works.


Both in the qbasic help and http://qbasicnews.com/qboho/


Title: Looking for a Command.
Post by: TheBigBasicQ on October 13, 2004, 01:19:46 PM
do you want to tokenize the string? i.e. break it up into small words?

For example:
s$ = "hi this is some string"

tokenize(s$) would break up the string into:

hi

this

is

some

string


Title: Looking for a Command.
Post by: Oz on October 13, 2004, 05:29:11 PM
[syntax="qbasic"]' A slightly more `workable` example

CLS

'Get 2 variables
INPUT "String: ", string1$
INPUT "Sub-string:", substring1$

'make them lower case.....jsut to be safe
string1$ = lcase$(string1$)
substring1$ = lcase$(substring1$)

'Find the substring....will return 0 if it isn't in the original string
'If it is there, it will tell you where it is located (index)
location% = INSTR(string1$, substring1$)

IF location% > 1 THEN

 'Get the length of the substring
 l% = len(substring1$)

 'Get a copy of the substring
 a$ = MID$(string1$, location%, l%)

 'This should be equal, but I'm just going to be thorough because I can be
 IF substring1$ = a$ THEN
  PRINT "Found "; substring1$; " in "; string1$
 END IF

END IF

'I hate using END but if im going to give an example, I should probably be thorough about it
END[/syntax]

Oz~


Title: Looking for a Command.
Post by: Licentia on October 14, 2004, 08:22:51 PM
Quote from: "TheBigBasicQ"
do you want to tokenize the string? i.e. break it up into small words?

For example:
s$ = "hi this is some string"

tokenize(s$) would break up the string into:

hi

this

is

some

string


  Yeah, I think that's what I want.  Basically I am trying to make lottery programs.  Here is a combo example:

  12 24 36 39 42 47

  I can get Qbasic to open that from a text file, but each combination becomes a single variable.  What I want then is to open the variable and divide the numbers into different variables.  12 - a 24 - b 36 - c 39 - d etc.

  I don't think the MID command will do that, now that i've looked at it a little.  I'll research the tokenize command.  Thanks.


Title: Looking for a Command.
Post by: Oz on October 14, 2004, 10:18:42 PM
tokenize isn't a built in command....

TBBQ was suggesting using the MID$() command in a subroutine to find what you want

Oz~


Title: Looking for a Command.
Post by: Oz on October 14, 2004, 10:34:36 PM
[syntax="qbasic"]
DECLARE FUNCTION num%(info AS STRING)
DECLARE FUNCTION find.word$(info AS STRING, index AS INTEGER)

blarg$="24 59 14 62 0"

number% = num%(blarg$)

FOR i% = 1 TO number%

 PRINT find.word$(blarg$, i%)

NEXT i%

FUNCTION num%(info AS STRING)

l% = LEN(info)

FOR a% = 1 TO l%
 temp$ = MID$(info, a%, 1)
 IF temp$ = " " THEN num% = num% + 1
NEXT

END FUNCTION

FUNCTION find.word$(info AS STRING, index AS INTEGER)

l% = LEN(info)

FOR a% = 1 TO l%

 temp$ = MID$(info, a%, 1)
 IF temp$ = " " THEN pl% = pl% + 1

 IF pl% = index THEN
  FOR b% = 1 TO (l% - a%)
   c$ = MID$(info, b%, 1)
   IF c$ = " " THEN
    find.word$ = MID$(info, a%, b%)
    EXIT FUNCTION
   END IF
  NEXT b%
 END IF

NEXT a%

END FUNCTION

[/syntax]

I think that pretty code should do the work nicely

Oz~


Title: Looking for a Command.
Post by: TheBigBasicQ on October 17, 2004, 09:00:17 AM
i dunno why you guyz got confused about my 'tokenize' question o.O

licentia heres a sample code which tokenizes a given string. You will have to modify it to make it a function ;).

[syntax="qbasic"]CLS

s$ = "I r teh 1337 sentence"

DO
    ps% = INSTR(s$, " ")

    IF INSTR(s$, " ") = 0 THEN
        PRINT s$
        EXIT DO
    ELSE
        PRINT LEFT$(s$, ps% - 1)
    END IF

    s$ = RIGHT$(s$, LEN(s$) - ps%)
LOOP
[/syntax]


Title: Re: Looking for a Command.
Post by: Licentia on October 18, 2004, 02:20:02 PM
Quote from: "whitetiger0990"
Quote from: "Licentia"
And does anyone know the website of that QBasic Advanced commands list?  It has the commands, and then you can click on most of them and then it gives instructions on how the command works.


Both in the qbasic help and http://qbasicnews.com/qboho/


  This is awesome.  http://qbasicnews.com/qboho/qck-9997.shtml

  That must be like every command.  I've never seen half of them.


Title: Looking for a Command.
Post by: Licentia on October 18, 2004, 02:32:13 PM
Quote from: "TheBigBasicQ"
i dunno why you guyz got confused about my 'tokenize' question o.O

licentia heres a sample code which tokenizes a given string. You will have to modify it to make it a function ;).

[syntax="qbasic"]CLS

s$ = "I r teh 1337 sentence"

DO
    ps% = INSTR(s$, " ")

    IF INSTR(s$, " ") = 0 THEN
        PRINT s$
        EXIT DO
    ELSE
        PRINT LEFT$(s$, ps% - 1)
    END IF

    s$ = RIGHT$(s$, LEN(s$) - ps%)
LOOP
[/syntax]


  I don't understand it, but thanks.  It works great!  I'll figure it out.

  Thanks to all the other people who've helped.


Title: Looking for a Command.
Post by: adosorken on October 18, 2004, 02:48:41 PM
Licentia: it works by seperating the string into pieces by way of splitting them at the spaces. The INSTR$ function finds the spaces and uses the value to know where to split up the string. It's pretty easy once you get the hang of the basics. :D


Title: Looking for a Command.
Post by: Licentia on October 18, 2004, 08:59:27 PM
Quote from: "adosorken"
Licentia: it works by seperating the string into pieces by way of splitting them at the spaces. The INSTR$ function finds the spaces and uses the value to know where to split up the string. It's pretty easy once you get the hang of the basics. :D


  Thanks for that clarification.  It definitely helps.


Title: Looking for a Command.
Post by: TheBigBasicQ on October 19, 2004, 08:56:09 AM
Quote from: "adosorken"
Licentia: it works by seperating the string into pieces by way of splitting them at the spaces. The INSTR$ function finds the spaces and uses the value to know where to split up the string. It's pretty easy once you get the hang of the basics. :D


what? no criticism :x


Title: Looking for a Command.
Post by: Neo on October 19, 2004, 01:17:58 PM
Quote from: "adosorken"
Licentia: it works by seperating the string into pieces by way of splitting them at the spaces. The INSTR$ function finds the spaces and uses the value to know where to split up the string. It's pretty easy once you get the hang of the basics. :D

There is no INSTR$ function... ;)
It's the INSTR function...

oh well... nvm ;)


Title: Looking for a Command.
Post by: adosorken on October 19, 2004, 10:56:27 PM
Quote from: "Neo"
Quote from: "adosorken"
Licentia: it works by seperating the string into pieces by way of splitting them at the spaces. The INSTR$ function finds the spaces and uses the value to know where to split up the string. It's pretty easy once you get the hang of the basics. :D

There is no INSTR$ function... ;)
It's the INSTR function...

oh well... nvm ;)

Oh stop being such fucking critics, both of you honkeys. :evil:


Title: Looking for a Command.
Post by: Licentia on October 20, 2004, 12:02:13 AM
Quote from: "adosorken"
Quote from: "Neo"
Quote from: "adosorken"
Licentia: it works by seperating the string into pieces by way of splitting them at the spaces. The INSTR$ function finds the spaces and uses the value to know where to split up the string. It's pretty easy once you get the hang of the basics. :D

There is no INSTR$ function... ;)
It's the INSTR function...

oh well... nvm ;)

Oh stop being such @$ critics, both of you honkeys. :evil:


  There seems to be a lot of competition and put downs at this forum.  Like knowing more about QBasic somehow makes you a star.  lol  :lol:  :rotfl:


Title: Looking for a Command.
Post by: adosorken on October 20, 2004, 12:44:11 AM
Quote from: "Licentia"
 There seems to be a lot of competition and put downs at this forum.  Like knowing more about QBasic somehow
makes you a star.  lol  :lol:  :rotfl:

It's the nature of the beast. You'll get used to it. :D


Title: Looking for a Command.
Post by: Neo on October 20, 2004, 05:13:15 AM
I only posted that because I was bored and wanted something to post, then I get picky about the details ;)

It wasn't meant seriously ado, and you know it :)


Title: Looking for a Command.
Post by: TheBigBasicQ on October 21, 2004, 08:04:07 AM
Quote from: "Licentia"
There seems to be a lot of competition and put downs at this forum.  Like knowing more about QBasic somehow makes you a star.  lol  :lol:  :rotfl:


There cant be any competition as long as I am here ;)


Title: Looking for a Command.
Post by: Neo on October 21, 2004, 08:40:43 AM
Why? :roll: :D


Title: Looking for a Command.
Post by: adosorken on October 21, 2004, 02:35:26 PM
Quote from: "TheBigBasicQ"
There cant be any competition as long as I am here ;)

Unfortunately for you, most people have yet to see you actually code anything. :lol:


Title: Looking for a Command.
Post by: TheBigBasicQ on October 23, 2004, 12:38:21 PM
adosorken:
i have coded enough =P and I have released enough ;). The last I remember, I was doing a Fake QB OS. But due to shortage of time I havent been able to complete it =(. I have to concentrate on my career. for now =P.


Title: Looking for a Command.
Post by: Licentia on October 26, 2004, 11:47:40 PM
Quote from: "TheBigBasicQ"
adosorken:
i have coded enough =P and I have released enough ;). The last I remember, I was doing a Fake QB OS. But due to shortage of time I havent been able to complete it =(. I have to concentrate on my career. for now =P.


  Make a new OS with Microsoft's abandoned programming language, and then destroy Windows with it.  :P   Make Billions in the process!  :P   Yeah, like that would ever happen.   :roll:   No one can destroy Windows.  :king:


Title: Looking for a Command.
Post by: TheBigBasicQ on October 27, 2004, 06:50:15 AM
erm...its called a fake OS


Title: Looking for a Command.
Post by: Oz on October 27, 2004, 11:12:23 AM
actually, in all technicallity, if we are saying that QB can't be an OS coz its dependant on DOS, then Windows up until recently wasn't a real OS either.
Iyt used to be heavily dependant on DOS

Oz~


Title: Looking for a Command.
Post by: Licentia on October 27, 2004, 03:24:49 PM
Quote from: "Oz"
actually, in all technicallity, if we are saying that QB can't be an OS coz its dependant on DOS, then Windows up until recently wasn't a real OS either.
Iyt used to be heavily dependant on DOS

Oz~


  A QBasic OS would be cool.


Title: Looking for a Command.
Post by: Z!re on October 27, 2004, 03:38:12 PM
http://www.Novix.tk

On hold though, I hate bugs... really... I do...


There's some more info in the Novix forum.


Title: Looking for a Command.
Post by: Oz on October 28, 2004, 05:05:58 PM
I uploaded my 'tokenizer' on quickhost.tk

here it is:
http://quickhost.qbtk.com/download.php?id=300

Oz~


Title: Looking for a Command.
Post by: Licentia on November 04, 2004, 11:07:41 PM
Quote from: "Oz"
I uploaded my 'tokenizer' on quickhost.tk

here it is:
http://quickhost.qbtk.com/download.php?id=300

Oz~


  Thanks.