Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking for a Command.
#1
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.
Reply
#2
Code:
MID$()
Reply
#3
Quote:
Code:
MID$()

So easy to find info on a command when you know what the command is. Thanks!
Reply
#4
Here: http://forum.qbasicnews.com/viewtopic.php?t=6991

I hope its usefull to ya, kinda looks like the same question
Reply
#5
Quote: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/
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#6
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
Reply
#7
[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~
Reply
#8
Quote: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.
Reply
#9
tokenize isn't a built in command....

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

Oz~
Reply
#10
[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~
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)