QB64.Net Homepage QB/QB64 Keywords QB Graphics Forum Homework Policy
How can I make my "AI" smarter?by (no login)I made a text based AI which can interpret what the user inputs - it uses a word parsing sub-procedure to parse the word and takes action based on the words.. it keeps things like your name, age and hobbies in memory as well. But how can i make it "think" for itself? This is my code : SCREEN _NEWIMAGE(1920, 1080, 32)'change resolution to your screen res. f& = _LOADFONT("C:\WINDOWS\Fonts\Lucon.ttf", 21) _SCREENMOVE 0, 0 _FONT f& spacenum = 0 declare function changePerson$' this changes the person(grammatically speaking) to 2nd person DIM SHARED NAME$ DIM SHARED numOfWords DIM SHARED numToCompare DIM SHARED space(1000) DIM SHARED word$(1000) DIM SHARED compareWord$(1000) DIM SHARED AGE$ DIM SHARED HOBBIES$ NAME$ = "someone" HOBBIES$ = "something...which I don't know about..." AGE$ = "I don't know how many" space(0) = 0 DO com$ = "" 'find function's second parameter is where it should start searching (Word number) ' find returns the location of the first word to find within the command LINE INPUT "Command : "; com$ parse (com$) 'parses a string, returns an array with words... IF find("end", 1) > 0 OR find("exit", 1) > 0 THEN SYSTEM IF find("I am", 1) <> 0 AND RIGHT$(com$, 9) = "years old" THEN AGE$ = word$(2 + find("I am", 1)) ELSEIF find("I am", 1) <> 0 AND RIGHT$(com$, 9) <> "years old" THEN NAME$ = word$(2 + find("I am", 1)) END IF IF find("who are you", 1) <> 0 OR find("who are you?", 1) <> 0 OR find("what are you", 1) <> 0 OR find("what are you?", 1) <> 0 THEN PRINT "My name is ALTAIR : Amazing Learning-Type Artificial Intelligence Robot" IF find("I like", 1) <> 0 THEN HOBBIES$ = RIGHT$(com$, LEN(com$) - 6) IF find("My name is", 1) <> 0 THEN NAME$ = word$(3 + find("My name is", 1)) PRINT "Hi "; NAME$; ". My name is ALTAIR : Amazing Learning-Type Artificial Intelligence Robot" END IF IF find("what's my name?", 1) <> 0 OR find("what is my name?", 1) <> 0 OR find("what is my name", 1) <> 0 OR find("what is my name", 1) <> 0 OR find("who am i?", 1) <> 0 OR find("who am i", 1) <> 0 THEN HOBBIES$ = changePerson$(HOBBIES$) PRINT "You are "; NAME$; " who is "; AGE$; " years old. You like "; HOBBIES$ END IF LOOP SUB parse (com$)'more efficient word parser than that used in CommandProcessor program space(0) = 0 spacenum = 0 FOR x = 1 TO LEN(com$) 'loop continues until end of command IF RIGHT$(LEFT$(com$, x), 1) = " " THEN 'finds a space spacenum = spacenum + 1 space(spacenum) = x word$(spacenum) = RIGHT$(LEFT$(com$, space(spacenum) - 1), space(spacenum) - space(spacenum - 1) - 1) END IF NEXT x spacenum = spacenum + 1 word$(spacenum) = RIGHT$(com$, LEN(com$) - space(spacenum - 1)) numOfWords = spacenum END SUB FUNCTION find (toFind$, StartSearch)'like INSTR but searches whole words only and returns the word position not character. parseToFind (toFind$) IF StartSearch <= numOfWords THEN FOR x = StartSearch TO numOfWords IF (x + numToCompare - 1) > numOfWords THEN GOTO theend ELSE compare$ = "" FOR ToCompare = 0 TO (numToCompare - 1) IF x + ToCompare <= numOfWords THEN compare$ = compare$ + " " + word$(x + ToCompare) NEXT ToCompare IF LCASE$(toFind$) = LCASE$(RIGHT$(compare$, LEN(compare$) - 1)) THEN find = x GOTO theend ELSE find = 0 END IF NEXT x ELSE find = 0 END IF theend: END FUNCTION SUB parseToFind (com$)'parser for find -- i didn't know how to allow function to use the regular parser without messing up the original words of the original command... space(0) = 0 spacenum = 0 FOR x = 1 TO LEN(com$) 'loop continues until end of command IF RIGHT$(LEFT$(com$, x), 1) = " " THEN 'finds a space spacenum = spacenum + 1 space(spacenum) = x compareWord$(spacenum) = RIGHT$(LEFT$(com$, space(spacenum) - 1), space(spacenum) - space(spacenum - 1) - 1) END IF NEXT x spacenum = spacenum + 1 compareWord$(spacenum) = RIGHT$(com$, LEN(com$) - space(spacenum - 1)) numToCompare = spacenum END SUB FUNCTION changePerson$ (toChange$)'changes person changed$ = "" space(0) = 0 spacenum = 0 FOR x = 1 TO LEN(toChange$) 'loop continues until end of command IF RIGHT$(LEFT$(toChange$, x), 1) = " " THEN 'finds a space spacenum = spacenum + 1 space(spacenum) = x word$(spacenum) = RIGHT$(LEFT$(toChange$, space(spacenum) - 1), space(spacenum) - space(spacenum - 1) - 1) IF LCASE$(word$(spacenum)) = "i" THEN word$(spacenum) = "you"' change i to you...doesn't change verbs though changed$ = changed$ + word$(spacenum) + " " END IF NEXT x spacenum = spacenum + 1 word$(spacenum) = RIGHT$(toChange$, LEN(toChange$) - space(spacenum - 1)) changed$ = changed$ + word$(spacenum) changePerson$ = changed$ END FUNCTION |
There are lots of ways to make a computer program "think" (decision trees, markov models, neural networks, et cetera), and which way is best really depends on what you're trying to accomplish.
It looks like you're writing a computer program that can carry on a conversation. I suppose you could look into "natural language processing", but I get the feeling that you want to do more than that: maybe "general ai" (aka "strong ai")? There is no sure-fire way of doing this so that you cannot determine whether you are having a conversation with a computer program or with a human. Imho, we lack the computer technology and the algorithms to do this well. However, the closest-to-perfect way of doing it that I know of is by using something like AIML (Artificial Intelligence Markup Language). |
*Thanks...I'll look into thatby (no login) |
http://en.wikipedia.org/wiki/Turing_test |
qb64 RUN keywordby lawgin (no login)RUN "some program.bas" always gives me a file not found error. RUN "some program.exe" does work. RUN in qb4.5 has no problem with the .bas extension. |
QB64 cannot RUN a BAS file. It must compile it first into an EXE.
|
OKby lawgin (no login)The qb64help file doesn't list RUN as a qb64 keyword, so I thought it was completely compatible with the qbasic usage. |
When used inside a program, RUN restarts a program or can RUN another one starting at a line number like RUN 12
http://qb64.net/wiki/index.php?title=RUN
|
*there's a qb64help file?by Ben (no login) |
Re: *there's a qb64help file?by lawgin (no login)http://www.qb64.net/forum/index.php?topic=1362.0 |
To work with a BAS file, your program or runtime would have to have a built in compiler or interpreter. It can work in QBASIC, because QBASIC is an interpreter. I don't think it would work with compiled QB4.5 programs. Regards, Michael |
QuickBasic dos to YouTube video.by (no login)I have some programs written in quick basic dos environment. I want to get the output to a video file and put a voice narration over it and ultimately upload to YouTube. Can I take the cable that goes to the monitor and somehow use that signal as a video input in some video device in order to create a video that I can input into a video editing program in Windows 7? Any ideas? Best way to proceed? Thanks in advance for your help. |
You might try screen capture software...by (Login qb432l)R There are a number of applications that will capture whatever appears on your screen and save it to a video file. I've never had need for one so couldn't recommend any, but I'm sure there are dozens of freeware or trial versions available. Go to Google/Yahoo and search "screen capture software".
As far as I know you can't feed a VGA signal into a recording device. If you had a video output from your graphics card -- such as S-Video -- then you'd have a number of options. Here's a third possibility -- a PC to RGB converter: http://www.converters.tv/products/vga_to_rgb/518.html -Bob
|
QB64 will always appear as a Window in a recording however. You can't capture it fullscreen.
Camtasia has some movie software for tutorials and such that record the desktop.
|
*Try "atube catcher"by (no login) |
RANDOMIZE questionby lawgin (no login)I thought RANDOMIZE n always produced the same sequence as long as n remains unchanged, but why does this code give 6 different numbers? RANDOMIZE 100 PRINT RND, RND, RND n = 100 RANDOMIZE n PRINT RND, RND, RND |
QB64 allows you to restart a sequence with USING:
RANDOMIZE 100 PRINT RND, RND, RND n = 100 RANDOMIZE USING n PRINT RND, RND, RND |
Good tip, thanksby lawgin (no login)I thought another RANDOMIZE restarted the sequence, but not so. |
Need help with text encoding programby (no login)I wrote a program which encodes text.. its basic (like a = z , b = y etc) but i added an "encryption key" to make it a bit better.. The program chooses between two lists (eg : in the first list a = z, but in the second 'a' might equal 'j') The encryption key is a series of 1's and 2's which tells the program which list to use.. Then the 1's and 2's are changed to character using the CHR$() function...it starts at a certain value and increments by 1 or two based on the key (eg : if the start value was 60 and the key was 11221, the text version would be CHR$(61),CHR$(62),CHR$(64),CHR$(66),CHR$(67) ) it usually works fine, but sometimes it skips a letter Theoretically the number of letters that the program outputs is equal to the number of the letters that the user inputs... however, i conducted a test run by typing 'hello' and checking the output.. every third trial or so , it skipped a letter and when i decoded it (the decoder program is separate: it works fine), it would result in a jumbled mess of characters.. This is the Source Code(its very long because i couldn't figure out how to compress it ) : SCREEN _NEWIMAGE(1600, 900, 32) f& = _LOADFONT("C:\WINDOWS\Fonts\Lucon.ttf", 21) _FONT f& _FULLSCREEN codenum = 1 DIM SHARED k DIM SHARED letter$ DIM SHARED Key$ DIM SHARED message$ DIM SHARED EncryptionKey$ DIM SHARED Start DIM SHARED Translation$ RANDOMIZE TIMER Start = INT(RND * 73) + 34 PRINT "Your Start value is : "; Start setKey encodeKey PRINT "'"; k; "'" PRINT "'"; Key$; "'" PRINT "Your Encryption Key is : "; EncryptionKey$ LINE INPUT "Enter Message : "; message$ encode PRINT "Translated : "; Translation$ SUB setKey RANDOMIZE TIMER FOR x = 0 TO 4 k = k + ((INT(RND * 2) + 1) * (10 ^ x)) NEXT x Key$ = RIGHT$(STR$(k), 5) END SUB SUB encodeKey FOR x = 1 TO 5 SELECT CASE (RIGHT$(LEFT$(Key$, x), 1)) CASE "1" Start = Start + 1 EncryptionKey$ = EncryptionKey$ + CHR$(Start) CASE "2" Start = Start + 2 EncryptionKey$ = EncryptionKey$ + CHR$(Start) END SELECT NEXT x END SUB SUB encode currentPlace = 0 place = LEN(message$) + 1 DO FOR x = 1 TO 5 currentPlace = currentPlace + 1 IF currentPlace >= place THEN GOTO subend codenum = VAL(RIGHT$(LEFT$(Key$, x), 1)) IF codenum = 2 THEN SELECT CASE LCASE$(RIGHT$(LEFT$(message$, currentPlace), 1)) CASE "a" letter$ = "z" CASE "b" letter$ = "y" CASE "c" letter$ = "x" CASE "d" letter$ = "w" CASE "e" letter$ = "v" CASE "f" letter$ = "u" CASE "g" letter$ = "t" CASE "h" letter$ = "s" CASE "i" letter$ = "r" CASE "j" letter$ = "q" CASE "k" letter$ = "p" CASE "l" letter$ = "o" CASE "m" letter$ = "n" CASE "n" letter$ = "m" CASE "z" letter$ = "a" CASE "y" letter$ = "b" CASE "x" letter$ = "c" CASE "w" letter$ = "d" CASE "v" letter$ = "e" CASE "u" letter$ = "f" CASE "t" letter$ = "g" CASE "s" letter$ = "h" CASE "r" letter$ = "i" CASE "q" letter$ = "j" CASE "p" letter$ = "k" CASE "o" letter$ = "l" CASE " " letter$ = " " END SELECT ELSEIF codenum = 1 THEN SELECT CASE LCASE$(RIGHT$(LEFT$(message$, currentPlace), 1)) CASE " " letter$ = " " CASE "a" letter$ = "/" CASE "b" letter$ = "." CASE "c" letter$ = "," CASE "d" letter$ = "'" CASE "e" letter$ = "" CASE "f" letter$ = "\" CASE "g" letter$ = "[" CASE "h" letter$ = "1" CASE "i" letter$ = "2" CASE "j" letter$ = "3" CASE "k" letter$ = "4" CASE "l" letter$ = "5" CASE "m" letter$ = "6" CASE "n" letter$ = "7" CASE "z" letter$ = "8" CASE "y" letter$ = "9" CASE "x" letter$ = "+" CASE "w" letter$ = "-" CASE "v" letter$ = "`" CASE "u" letter$ = "~" CASE "t" letter$ = "|" CASE "s" letter$ = "*" CASE "r" letter$ = "=" CASE "q" letter$ = "_" CASE "p" letter$ = "}" CASE "o" letter$ = "{" CASE "/" letter$ = "a" CASE "." letter$ = "b" CASE "," letter$ = "c" CASE "'" letter$ = "d" CASE "" letter$ = "e" CASE "\" letter$ = "f" CASE "[" letter$ = "g" CASE "1" letter$ = "h" CASE "2" letter$ = "i" CASE "3" letter$ = "j" CASE "4" letter$ = "k" CASE "5" letter$ = "l" CASE "6" letter$ = "m" CASE "7" letter$ = "n" CASE "8" letter$ = "z" CASE "9" letter$ = "y" CASE "+" letter$ = "x" CASE "-" letter$ = "w" CASE "`" letter$ = "v" CASE "~" letter$ = "u" CASE "|" letter$ = "t" CASE "*" letter$ = "s" CASE "=" letter$ = "r" CASE "_" letter$ = "q" CASE "}" letter$ = "p" CASE "{" letter$ = "o" END SELECT ELSE PRINT "Not Valid"; codenum; " " END IF Translation$ = Translation$ + letter$ NEXT x LOOP WHILE currentPlace <= place subend: END SUB |
Looks like a mistypeby lawgin (no login)CASE "e" letter$ = "" If codenum is 1 and the letter is e, an empty string is assigned to letter$. Hence the missing letter. |
*Thanks.. i would've never caught that.. lolby (no login) |
You can shorten those CASE statementsby (no login) |
*How?by (no login) |
I think he meant you can put them on one line...by (Login qb432l)R CASE "a": letter$ = "z"
'You might also consider something like the following (would save a lot of typing). source$ = "abcdefg" coded$ = "cdefghi" TestCharacter$ = "e" letter$ = MID$(coded$, INSTR(source$, TestCharacter$), 1) PRINT letter$ 'The fifth character in the source string ("e") corresponds to the fifth character in the coded string ("g"). -Bob
|
Or don't use SELECT CASE at all...by lawgin (no login)I've replaced the first SELECT CASE with just 4 lines of code and it appears to be working well. You just have to add another space at the end of scram$ since this forum only allows single spaces. SCREEN _NEWIMAGE(1600, 900, 32) f& = _LOADFONT("C:\WINDOWS\Fonts\Lucon.ttf", 21) _FONT f& _FULLSCREEN codenum = 1 DIM SHARED k DIM SHARED letter$ DIM SHARED Key$ DIM SHARED message$ DIM SHARED EncryptionKey$ DIM SHARED Start DIM SHARED Translation$ RANDOMIZE TIMER Start = INT(RND * 73) + 34 PRINT "Your Start value is : "; Start setKey encodeKey PRINT "'"; k; "'" PRINT "'"; Key$; "'" PRINT "Your Encryption Key is : "; EncryptionKey$ LINE INPUT "Enter Message : "; message$ encode PRINT "Translated : "; Translation$ SUB setKey RANDOMIZE TIMER FOR x = 0 TO 4 k = k + ((INT(RND * 2) + 1) * (10 ^ x)) NEXT x Key$ = RIGHT$(STR$(k), 5) END SUB SUB encodeKey FOR x = 1 TO 5 SELECT CASE (RIGHT$(LEFT$(Key$, x), 1)) CASE "1" Start = Start + 1 EncryptionKey$ = EncryptionKey$ + CHR$(Start) CASE "2" Start = Start + 2 EncryptionKey$ = EncryptionKey$ + CHR$(Start) END SELECT NEXT x END SUB SUB encode currentPlace = 0 place = LEN(message$) + 1 DO FOR x = 1 TO 5 currentPlace = currentPlace + 1 IF currentPlace >= place THEN GOTO subend codenum = VAL(RIGHT$(LEFT$(Key$, x), 1)) IF codenum = 2 THEN 'begin change scram$ = "-az-by-cx-dw-ev-fu-gt-hs-ir-jq-kp-lo-mn-nm-za-yb-xc-wd-ve-uf-tg-sh-ri-qj-pk-ol- " pick$ = "-" + LCASE$(RIGHT$(LEFT$(message$, currentPlace), 1)) pick = INSTR(scram$, pick$) + 2 letter$ = MID$(scram$, pick, 1) 'end change ELSEIF codenum = 1 THEN SELECT CASE LCASE$(RIGHT$(LEFT$(message$, currentPlace), 1)) CASE " " letter$ = " " CASE "a" letter$ = "/" CASE "b" letter$ = "." CASE "c" letter$ = "," CASE "d" letter$ = "'" CASE "e" letter$ = "]" CASE "f" letter$ = "\" CASE "g" letter$ = "[" CASE "h" letter$ = "1" CASE "i" letter$ = "2" CASE "j" letter$ = "3" CASE "k" letter$ = "4" CASE "l" letter$ = "5" CASE "m" letter$ = "6" CASE "n" letter$ = "7" CASE "z" letter$ = "8" CASE "y" letter$ = "9" CASE "x" letter$ = "+" CASE "w" letter$ = "-" CASE "v" letter$ = "`" CASE "u" letter$ = "~" CASE "t" letter$ = "|" CASE "s" letter$ = "*" CASE "r" letter$ = "=" CASE "q" letter$ = "_" CASE "p" letter$ = "}" CASE "o" letter$ = "{" CASE "/" letter$ = "a" CASE "." letter$ = "b" CASE "," letter$ = "c" CASE "'" letter$ = "d" CASE "" letter$ = "e" CASE "\" letter$ = "f" CASE "[" letter$ = "g" CASE "1" letter$ = "h" CASE "2" letter$ = "i" CASE "3" letter$ = "j" CASE "4" letter$ = "k" CASE "5" letter$ = "l" CASE "6" letter$ = "m" CASE "7" letter$ = "n" CASE "8" letter$ = "z" CASE "9" letter$ = "y" CASE "+" letter$ = "x" CASE "-" letter$ = "w" CASE "`" letter$ = "v" CASE "~" letter$ = "u" CASE "|" letter$ = "t" CASE "*" letter$ = "s" CASE "=" letter$ = "r" CASE "_" letter$ = "q" CASE "}" letter$ = "p" CASE "{" letter$ = "o" END SELECT ELSE PRINT "Not Valid"; codenum; " " END IF Translation$ = Translation$ + letter$ NEXT x LOOP WHILE currentPlace <= place subend: END SUB |
*Thanks, I'll try thatby (no login) |
for exampleby (no login)it looks to me like that entire first select case block can be replaced by a simple expression letter$ = CHR$(122 - (ASC(LCASE$(RIGHT$(LEFT$(message$, currentPlace), 1))) - 97)) |
Exactly George...by Pete (no login)I didn't check the math, but provided you got it right, these types of pattern algorithms are the best solutions. |
Using ASCII values to reverse or shift encryptionby Solitaire (Login Solitaire1)S Here are two versions of an encryption program. The first is a simplified version using the reverse order of all the printable ASCII values to encrypt the message. The second uses a function to return the encrypted message. It uses a key to shift the ASCII values rather than reversing them, by either a user-selected or a random number. It includes a menu that also allows the option to decrypt the message. IT LOOKS LIKE THE LESS-THAN SYMBOL DIDN'T GET PRINTED HERE!! I am replacing it with the [ symbol instead. Please make that change in your program if you copy it. ==================================================================================================== DIM N AS INTEGER, x AS INTEGER, V AS INTEGER, R AS INTEGER first = 32: last = 126 =============================================================================================== DECLARE FUNCTION decode$ (coded AS STRING) CASE "2" FUNCTION code$ (message AS STRING, ikey AS INTEGER) FUNCTION decode$ (coded AS STRING)
|
*Thanks.. what does LTRIM$ do?by (no login) |
LTRIM$() removes the spaces to the left of the string.by Solitaire (Login Solitaire1)S Negative numbers have a - symbol, and positive numbers have a space to the left instead of a +. When you convert a positive number to a string, it includes the space, which you need to remove. In addition to LTRIM$ ,QB also has RTRIM$.
|
I revised the code in the above post. It now uses a hex key.by Solitaire (Login Solitaire1)S I did the second version a long time ago. Now when I looked at it more carefully, I noticed that there was a variable named hexkey$ that hadn't been used in either of the functions. They weren't really needed, but then I realized that I probably intended to use the hex value instead of the decimal value to add the key number onto the end of the encrypted message. This would make the encrypted message harder to understand, but the decimal key number is needed by the code in order to decrypt it. So I decided to employ the hex code in the code function. The last few lines are now shorter, after removing the random character that I'd used previously. The decode function translates the hex key into decimal with the VAL function. The code I had deleted from the post right after the NEXT x was: NEXT x I replaced it with: NEXT x
|
*oh...Ok...Thanksby (no login) |
splitting a screen verticallyby (no login)I want to split a screen vertically so that I can have scrolling text in one half and a fixed graphic in the other half. Is there any simple way I can do this please? |
I think this is what you mean by vertical. Otherwise, you'd just use VIEW PRINT. If you meant that you want a scroll bar so you can scroll a buffer up and down, this program doesn't do that. the variable names are cumbersome enough that I wouldn't rule out having misspelled a few. I wouldn't mind having '$option explicit. Regards, Michael -------------------------------- 'public domain, jan 2012, michael calkins DECLARE SUB customcls () DECLARE SUB customprint (text AS STRING) DECLARE SUB customprintcrlf () DECLARE SUB customscroll () CONST custommaxlines = 30 CONST custommaxcolumns = 40 CONST customcolumnoffset = 40 DIM SHARED customtextbuffer AS STRING * 1200 DIM SHARED customcolorbuffer AS STRING * 1200 DIM SHARED customline AS INTEGER DIM SHARED customcolumn AS INTEGER DIM SHARED customcolor AS INTEGER SCREEN 12 LINE (0, 0)-(319, 479), &HB LINE (0, 479)-(319, 0), &HD customline = 0 customcolumn = 0 customcolor = &H7 customprint "Hello World" customline = 3 customcolumn = 25 customcolor = &HF customprint "This will continue on the next line." customprintcrlf customcolor = &HC customprint "New line." customcolor = &HB customprint " No new line." customcolor = &HE customline = custommaxlines - 2 customcolumn = 0 customprint "Hold Shift down to see scrolling." customprintcrlf customprint "Press any normal key to stop." DO SLEEP customprint "." LOOP UNTIL LEN(INKEY$) customprintcrlf customprint "convert numbers to strings before passing them to me." + STR$(123.45) customline = custommaxlines + 10 customprint "and you can scroll multiple lines at once." customprintcrlf customprint "press any key twice to see a cls demo." SLEEP DO LOOP WHILE LEN(INKEY$) customcls SLEEP DO LOOP WHILE LEN(INKEY$) customline = custommaxlines - 1 customprint "press any key to overwrite this line" SLEEP DO LOOP WHILE LEN(INKEY$) END SUB customcls DIM i AS INTEGER customtextbuffer = "" FOR i = 0 TO custommaxlines - 1 LOCATE i + 1, 1 + customcolumnoffset PRINT SPACE$(custommaxcolumns); NEXT customline = 0 customcolumn = 0 END SUB SUB customprint (text AS STRING) DIM i AS INTEGER FOR i = 1 TO LEN(text) IF customcolumn >= custommaxcolumns THEN customcolumn = 0 customline = customline + 1 END IF IF customline >= custommaxlines THEN customscroll LOCATE customline + 1, customcolumn + 1 + customcolumnoffset COLOR customcolor PRINT MID$(text, i, 1); MID$(customtextbuffer, 1 + customline * custommaxcolumns + customcolumn, 1) = MID$(text, i, 1) MID$(customcolorbuffer, 1 + customline * custommaxcolumns + customcolumn, 1) = CHR$(customcolor) customcolumn = customcolumn + 1 NEXT END SUB SUB customprintcrlf customcolumn = 0 customline = customline + 1 IF customline >= custommaxlines THEN customscroll END SUB SUB customscroll DIM n AS INTEGER DIM i AS INTEGER n = 1 + customline - custommaxlines IF n > custommaxlines THEN n = custommaxlines FOR i = 0 TO custommaxlines - 1 IF (i + n) >= custommaxlines THEN MID$(customtextbuffer, 1 + i * custommaxcolumns, custommaxcolumns) = SPACE$(custommaxcolumns) MID$(customcolorbuffer, 1 + i * custommaxcolumns, custommaxcolumns) = STRING$(custommaxcolumns, customcolor) ELSE MID$(customtextbuffer, 1 + i * custommaxcolumns, custommaxcolumns) = MID$(customtextbuffer, 1 + (i + n) * custommaxcolumns, custommaxcolumns) MID$(customcolorbuffer, 1 + i * custommaxcolumns, custommaxcolumns) = MID$(customcolorbuffer, 1 + (i + n) * custommaxcolumns, custommaxcolumns) END IF NEXT FOR i = 0 TO custommaxlines - 1 LOCATE i + 1, 1 + customcolumnoffset FOR n = 0 TO custommaxcolumns - 1 COLOR ASC(MID$(customcolorbuffer, 1 + i * custommaxcolumns + n, 1)) PRINT MID$(customtextbuffer, 1 + i * custommaxcolumns + n, 1); NEXT NEXT customline = custommaxlines - 1 END SUB |
qb64by (no login)qb64 would involve _putimage and just a simple text scrolling routine. i'd use qb64 to do it. |
thanksby (no login)Thankyou for both replies. I couldn't get putimage to do what I wanted but Michael's program has given me the approach needed. |
|
Retrieving QB64 code from an exe?by Zack (no login)Hi, I deleted the new version of my source code and only have an old version. But I do have the exe compiled from the lost new source code. I can't remember how I did something and I was wondering if there was a way to extract the QB64 code from the exe so I can save it. ~Zack :) |
Were you just working on the source code?by Galleon (no login)If so, open QB64 again and keep using CTRL+Z to undo. The program could still be in the undo buffer. |
Some more info...by Galleon (no login)QB64's undo buffer keeps the last 100MB (or more if you set it higher) of program changes and does not erase the buffer if you exit QB64 and start it up again. In fact it never clears the buffer until it's full, then it starts to eat away at the oldest content. If it isn't in the undo buffer then I'm afraid you've lost it! While technically it is possible to decompile an executable file into a working program the difficulty of doing so and cost of specialist help required is never worth it. Variable names are also lost during QB64 compilation. |
Okby Zack (no login)Ok thanks, I guess Ill just have to figure out whats different between the two and recreate it. |
If you haven't compiled anything else since you compiled it, you'll still have the C++ source that QB64 generated in one of the temp subfolders in the internal subfolder. It's not as good as the source, but it's better than disassembling the executable, because at least you'll still have variable names, and the program structure will be more obvious. Regards, Michael P.S. It seems that just opening QB64 (even without compiling anything) can overwrite those files, so it might not be an option.
|
How do you make an enemy move?by (no login)So I'm trying to make an RPG game, I want to know how I can move enemys without crashing into walls. I'm pretty new at this so you might have to explain it a bit. Thanks. |
You can use POINT or the SCREEN function in ASCII games to find the wall color or make up a map array of where the walls are to find them.
Before you move the sprite, make sure that you CAN move there. If you need to find the screen borders make sure the coordinates do not exceed the screen size. |
Re: How do you make an enemy move?by Rick4551 (no login)Well I already used arrays for my map to stop the actual player from going through the walls. But I really need to know how the enemies/AI move on their own and without crashing into walls. I had an idea of putting it into a loop but it would just loop the enemy movement and the actual you won't be able to move your guy. |
Here's a little program that explains it...by (Login qb432l)R It takes a bit of study, but once you understand the concepts, you can create any type of game play area and have AI pieces navigate that area as if they know where they're going -- but with all movement randomly generated. Their location on the map can be established by adding 100 to the square's value while they're there so your player knows if an enemy is there. Good luck! -Bob 'Copy code from here ------------------------------------------------------ 'AI NAVIGATION OF A PATH: Press F5 to run. 'A 2-dimensional array is dimmed representing a 16x24 square play area DIM Map(1 TO 24, 1 TO 16) AS INTEGER 'DATA reflects the values of the play area: 1 is non-path, 0 is straight 'path with no intersections, and intersections have values as follows... MapDATA: DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 DATA 1, 6, 0, 0, 0, 0, 14,0, 0, 0, 0, 0, 14,0, 0, 0, 14,0, 14,0, 14,0, 12,1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 7, 0, 15,0, 15,0, 13,1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 DATA 1, 7, 0, 0, 14,0, 15,0, 0, 14,0, 0, 13,1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 DATA 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 7, 0, 0, 0, 15,0, 11,0, 11,0, 13,1 DATA 1, 7, 0, 0, 11,0, 13,1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 7, 0, 0, 0, 15,0, 0, 0, 0, 0, 13,1 DATA 1, 7, 0, 0, 0, 0, 13,1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 DATA 1, 0, 1, 1, 1, 1, 7, 0, 0, 11,0, 0, 13,1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 DATA 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 DATA 1, 3, 0, 0, 0, 0, 11,0, 0, 0, 0, 0, 11,0, 0, 0, 11,0, 0, 0, 0, 0, 9, 1 DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 'To begin with, each of the four possible directions of travel are 'represented by the lower four bits of a byte: 1, 2, 4 and 8. The "UP" 'direction is given a value of 1, "RIGHT" gets a value of 2, "DOWN" gets 'a value of 4, and "LEFT" a value of 8. 'An intersection's value then, is simply an addition of these values 'depending on which directions are possible. For example, the bottom- 'left turn in the grid has only two possible directions: "UP" and '"RIGHT", therefore its value is 1 + 2 = 3. An intersection wherein 'all directions are possible is valued as 1 + 2 + 4 + 8 = 15. I'm 'sure you get the idea. 'The direction an AI game piece is coming from is given the value of 'that direction. The variable "ExDIRECTION", for example, will have a 'value of 2 if the AI game piece is coming from the right. 'NOW... 'As the AI game piece moves, its Row and Column variables (Row/Col) are 'constantly updated based on the direction of travel. If the piece is 'moving to the left, then Col = Col - 1, etc.. 'Before the piece moves, its position relative to the map is checked. 'Map(Col, Row) will give us this value. If the value of that array 'element is zero, the piece simply continues along in the direction 'it has been going. If, on the other hand, the square has a value, 'then it is known to be an intersection and a turn must be determined. 'To begin with, there is a random value generated representing the 'four turns (1, 2, 4 and 8): 'NewDIRECTION = INT(RND * 4) + 1 'This will give a value of 1, 2, 3 or 4. Then we simply say: 'IF NewDIRECTION = 3 THEN NewDIRECTION = 8 'Hence, 1, 2, 4 or 8 are generated. 'Then we do what is called a bit-wise comparison of this random value 'with the intersection to see if our randomly-chosen turn is possible 'at that intersection. We simply AND NewDIRECTION with Map(Col, Row). 'Basically, what this is asking is, does my random turn exists at this 'intersection? If, for example, the random turn is 1 (UP) and the 'value of the intersection is 3 (UP/RIGHT), then the answer comes back 'YES (in other words, the 1-bit is set in the value 3 [0011]. This 'means that an "UP" turn is legal. The next thing that must be deter- 'mined is if the random turn is where we came from. If it is, then we 'try again, otherwise we'd constantly be bouncing off intersections 'rather than going through them. This is simply a case of comparing 'the NewDIRECTION variable with the ExDIRECTION variable to make sure 'they're not the same. 'The whole thing is enclosed in a DO loop that just keeps looping 'until it gets a viable result: 'DO 'Choose random direction (NewDIRECTION will = 1, 2, 4 or 8) 'LOOP UNTIL ((Map(Col, Row)) AND NewDIRECTION) '---line continues--- AND (NewDIRECTION <> ExDIRECTION) 'The above loop will execute instantaneously and with a viable turn. 'Now we have a new direction of travel, as well as a new "ExDIRECTION". 'The x/y increments are set accordingly and Row and Col are updated with 'each iteration of the main loop. 'ACTUAL PROGRAM BEGINS HERE ------------------------------------------------ 'Read DATA into map array RESTORE MapDATA FOR Row = 1 TO 16 FOR Col = 1 TO 24 READ Map(Col, Row) NEXT Col NEXT Row SCREEN 12 PALETTE 4, 63 'bright red for moving square 'Draw play area based on values in the array Row = 0: Col = 0 FOR x = 80 TO 540 STEP 20 Col = Col + 1 FOR y = 80 TO 380 STEP 20 Row = Row + 1 IF Map(Col, Row) <> 1 THEN Colr = 1 ELSE Colr = 9 LINE (x, y)-(x + 19, y + 19), Colr, BF NEXT y Row = 0 NEXT x COLOR 7 LOCATE 4, 31: PRINT "AI NAVIGATION OF A PATH" LOCATE 27, 33: PRINT "PRESS SPACE TO QUIT" 'Initialize AI game piece postion, both in terms of the array (Row/Col) 'and in graphical terms (x/y): Row = 2: Col = 2 x = 100: y = 100 Speed = 2 'increase to slow/decrease to speed up 'Start the main loop DO LINE (x, y)-(x + 19, y + 19), 1, BF 'erase old game piece postion IF Map(Col, Row) <> 0 THEN 'make sure we're at an intersection 'NOTE: We are at an intersection to begin with which is why there 'was no need to initialize the variable ExDIRECTION '------------------- the random loop explained above -------------------- DO NewDIRECTION = INT(RND * 4) + 1 IF NewDIRECTION = 3 THEN NewDIRECTION = 8 LOOP UNTIL (Map(Col, Row) AND NewDIRECTION) AND (NewDIRECTION <> ExDIRECTION) '------------------------------------------------------------------------ END IF 'Establish increments, Row/Col changes based on NewDIRECTION (which 'remains unchanged if the square was a zero). SELECT CASE NewDIRECTION CASE 1: IncX = 0: IncY = -20: Row = Row - 1: ExDIRECTION = 4 CASE 2: IncX = 20: IncY = 0: Col = Col + 1: ExDIRECTION = 8 CASE 4: IncX = 0: IncY = 20: Row = Row + 1: ExDIRECTION = 1 CASE 8: IncX = -20: IncY = 0: Col = Col - 1: ExDIRECTION = 2 END SELECT x = x + IncX: y = y + IncY 'graphical x/y incrementation 'Draw/PUT game piece LINE (x, y)-(x + 19, y + 19), 4, BF CIRCLE (x + 10, y + 10), 6, 14 PAINT STEP(0, 0), 14 'Wait for retrace (creates adequate pause so we see the game piece) FOR Delay = 1 TO Speed WAIT &H3DA, 8 WAIT &H3DA, 8, 8 NEXT Delay a$ = INKEY$ 'check for exit request LOOP UNTIL a$ = " " 'main loop terminates
|
The program knows where you are so move the enemy in that direction. If it encounters a wall, it will have to move in a free direction trying to move toward you in a column or row direction. |
it could get trappedby Ben (no login)http://en.wikipedia.org/wiki/Pathfinding read this, try to post some code here that works somehow like your game for the members here could adapt to your situation in their solutions |
Going towards a different approachby Rick4551 (no login)Ok so I'm going for a different approach. Instead of having the enemy move and attack on its own I'll just make it intiate a battle, where you pick to attack, defend or heal and the computer does the same. I did all that but now my main problem is that everytime the battle ends I can't move the person anymore, I've tried exit do which doesn't help. Here is the part of the code: Drawmaps are a sub drawmap col% = 3 row% = 3 x% = 16 y% = 16 score% = 0 PUT (88, 112), glass() PUT (x%, y%), hero() herohealth% = 100 heroarmor% = 100 DO '*****************************movement code k$ = INKEY$ IF k$ = CHR$(0) + CHR$(77) THEN 'right arrow key IF MID$(map$(row%), col% + 1, 1) = " " THEN PUT (x%, y%), hero() x% = x% + 8 col% = col% + 1 PUT (x%, y%), hero() score% = score% + 1 END IF ELSEIF k$ = CHR$(0) + CHR$(75) THEN 'left arrow key IF MID$(map$(row%), col% - 1, 1) = " " THEN PUT (x%, y%), hero() x% = x% - 8 col% = col% - 1 PUT (x%, y%), hero() score% = score% + 1 END IF ELSEIF k$ = CHR$(0) + CHR$(80) THEN 'down arrow key IF MID$(map$(row% + 1), col%, 1) = " " THEN PUT (x%, y%), hero() y% = y% + 8 row% = row% + 1 PUT (x%, y%), hero() score% = score% + 1 END IF ELSEIF k$ = CHR$(0) + CHR$(72) THEN 'up arrow key IF MID$(map$(row% - 1), col%, 1) = " " THEN PUT (x%, y%), hero() y% = y% - 8 row% = row% - 1 PUT (x%, y%), hero() score% = score% + 1 END IF '**********************end of movement code END IF LOCATE 1, 1 PRINT "Score:"; score% LOCATE 2, 2 PRINT x%; " "; y% LOCATE 1, 27 PRINT "Health:"; herohealth% LOCATE 2, 27 PRINT "Armor: "; heroarmor% IF x% = 88 AND y% = 112 THEN PUT (280, 40), arrow() END IF IF x% = 296 AND y% = 40 THEN CLS drawmap2 x% = 8 y% = 40 col% = 2 row% = 6 PUT (x%, y%), hero() PUT (16, 64), badguy() PUT (64, 24), badguy() PUT (120, 40), badguy() PUT (136, 40), badguy() PUT (184, 40), badguy() END IF IF x% = 16 AND y% = 64 OR x% = 64 AND y% = 24 OR x% = 120 AND y% = 40 OR x% = 136 AND y% = 40 OR x% = 184 AND y% = 40 THEN enemhealth% = 100 enemarmor% = 100 '**************************battlemap DO CLS OPEN "J:\qb\btlmap.txt" FOR INPUT AS #9 row% = 0 mapx% = 0 mapy% = 0 DO row% = row% + 1 LINE INPUT #9, map$(row%) FOR col% = 1 TO LEN(map$(row%)) IF MID$(map$(row%), col%, 1) = "w" THEN PUT (mapx%, mapy%), map() END IF mapx% = mapx% + 8 NEXT col% mapx% = 0 mapy% = mapy% + 8 LOOP UNTIL EOF(9) CLOSE #9 PUT (96, 64), hero() PUT (208, 64), badguy() '***************************end of battlemap drawing LOCATE 14, 9 PRINT "Please choose something:" LOCATE 16, 10 COLOR 47 PRINT "D: Defend" LOCATE 18, 10 COLOR 40 PRINT "A: Attack" LOCATE 20, 10 COLOR 54 PRINT "H: Heal" LOCATE 1, 1 PRINT "Score:"; score% LOCATE 1, 20 PRINT "Your health:"; herohealth% LOCATE 2, 20 PRINT "Your armor: "; heroarmor% LOCATE 4, 20 PRINT "Enemy health:"; enemhealth% LOCATE 5, 20 PRINT "Enemy armor:"; enemarmor% LOCATE 22, 9 INPUT opt2$ enemopt% = RND + 1 enemattak% = RND * 10 + 10 heroattak% = RND * 10 + 10 IF UCASE$(opt2$) = "D" THEN 'defending code ELSEIF UCASE$(opt2$) = "A" THEN 'attack code ELSEIF UCASE$(opt2$) = "H" THEN 'healing code END IF IF herohealth% <= 0 THEN 'cut the code for the game over screen END IF IF enemhealth% <= 0 THEN CLS drawmap2 x% = x% + 8 'this the that's giving me problems col% = col% + 1 'don't know how to get the game to show PUT (x%, y%), hero() score% = score% + 150 EXIT DO END IF LOOP END IF LOOP UNTIL k$ = CHR$(27) 'esc key to end |
Re: Going towards a different approachby Rick4551 (no login)Never mind I found the problem but thanks for the help. :) |
Move It -- Just for funby Solitaire (Login Solitaire1)S My back went out several weeks ago (the day before New Year's Eve) and I've had a lot of trouble moving around. At my age, it's taking a long time to recover and I've been homebound for the most part. (I was home alone watching the Times Square ball drop on TV.) My son drove me to school on the days I had to teach. My students helped open doors, carry my stuff and pass around the handouts. Just for fun, I wrote a short QB program to move a smiling face across, down, and diagonally across the screen. It moves faster than I can. CLS FOR x = 2 TO 23 LOCATE 3, 30 LOCATE 10, 35: PRINT "_ _"
|
Thanks for sharing...I know how you feel.
![]() |
Solitaire, I love your programsby AlGoreIthm (no login)Please Get Well Soon! ============================================================================== CLS heading$(1) = "Move Across" heading$(2) = "Move Down " heading$(3) = "Move Diagonally" limit%(1) = 80: stp%(1) = 2 limit%(2) = 23: stp%(2) = 1 limit%(3) = 80: stp%(3) = 4 FOR round% = 1 TO 3 COLOR 7: LOCATE 2, 30: PRINT heading$(round%) COLOR 14 y% = 4 FOR x% = 2 TO limit%(round%) STEP stp%(round%) IF round% = 2 THEN LOCATE x%, y% ELSE LOCATE y%, x% PRINT CHR$(1) t = TIMER DO WHILE (t + .12) >= TIMER LOOP IF round% = 2 THEN LOCATE x%, y% ELSE LOCATE y%, x% PRINT " " IF round% = 3 THEN y% = y% + 1 NEXT x%, round% LOCATE 9, 32: PRINT CHR$(218); STRING$(9, CHR$(196)); CHR$(191) FOR x = 10 TO 15 LOCATE x, 32: PRINT CHR$(179); TAB(42); CHR$(179) NEXT x LOCATE x, 32: PRINT CHR$(192); STRING$(9, CHR$(196)); CHR$(217) LOCATE 10, 35: PRINT "_ _" LOCATE 11, 35: PRINT CHR$(239); " "; CHR$(239) LOCATE 13, 37: PRINT "^" LOCATE 14, 35: PRINT "\___/" COLOR 7 LOCATE 20, 36: PRINT "OK" END
|
Interesting revisionby Solitaire (Login Solitaire1)S I made a slight correction in 3 places where double or triple spaces should have been instead of a single space after it was posted. It did look a bit off when I ran it -- the eyes were not centered, and the "Move down" didn't cover the previous "s" I added Alt(255) to those 3 places in my post as well as in yours. I had never before seen a single NEXT instruction to include the ending of two loops, the way you have it. Interesting. I used variables instead of literals when creating the face. That made it a lot easier to center and size the box, and place the features correctly. Glad you liked it.
|
*LOL - I get "moves faster than I can". My back went out recently, lasted two weeks.by (Login qb432l)R * |
Colors and Patterns -- with link to a subforum for the codeby Solitaire (Login Solitaire1)S I posted the program code to the "Big Programs" subforum, even though it's not all that big. I don't understand how the "Proud" subforum works. I have 81 "replies" listed under my name, with dozens of programs, all of them using a single url. How can the individual programs be separated and accessed? Here is the program I wrote a while back and revised a few days ago. It has multiple options for changing the foreground color, background color, text color, and non-alphanumeric characters to create hundreds of various patterns. It displays the values of all the combinations, so a designer can select the pattern combination of choice, and use those values to create a pleasing screen for whatever purpose is needed. Enjoy!
|
*Nice work -- lots of fun exploring the myriad combinations.by (Login qb432l)R *
|
at: ELSE 'will use ASCII value of valid input number w = ASC(sv$) 'new character will assume CHR$ of ASCII value I think it should be something like: ELSEIF v > 0 THEN w = v ELSE w = ASC(sv$) Regards, Michael
|
Is it really needed?by Solitaire (Login Solitaire1)S That would account for any values I had omitted, but I think all of them were accounted for. Is there anything that was left out? Instead, I need to add another condition to the end of the line beginning with ELSEIF v = 7 to test for IF v is less than 0 and include it in the nested IF block testing for the correct range. I made that change in the program listing.
|
There is no mechanism to set w = v. So, if I press "c", then type "254", I see "2" instead of "■". Likewise, if I press "c", then type "&hfe", I see "&" instead of "■". My suggested change was probably not the best or most efficient fix. It was just a small hack that would make the ASCII value entry work. Regards, Michael |
Solitaire, Would you Consider -by AlGoreIthm (no login)Rather than using a numeric system for those characters, use a long string that incorporates all the characters you want to allow and then programming that section accordingly. This would greatly simplify many of your IF-THEN (ELSE lines because all you need really to check for is re-setting the end of the string back to 1. One of the advantages of using a long string of characters is that you can actually create the consecutive order that the characters will appear in: EX: the following are not in ASC order: "!@#*&^$%" , but they would appear in the order you see in the string, so you get to set it up exactly the way you want it to come out. |
OK. I fixed it.by Solitaire (Login Solitaire1)S Thanks for the feedback. My original program used: ELSE w = v but with all the extra options I added, it resulted in a solid black background. I tested it with single characters but didn't anticipate that the ASCII numbers would no longer work. I added a new string variable - sv1$ - to test for the VAL of the first character. If it was 0 and not "0" then I made sv$ = sv1$ I added this to the condition that also tested single digits to use the ASCII value of the first character. Then changed the ELSE to w = v. It should be working fine now. I revised the program code in the subforum to reflect the changes. ============================================================ About the suggestion to use a long string instead of multiple ELSEIFs, that would be very impractical. First of all, most of those characters are not on the keyboard and it would require a CHR$() with each one of those. Secondly, with the numbers in code, you can see exactly which values are being skipped.
|
context menusby Ben (no login)what would be a good data structure to store content for sub menus & sub sub sub... menus etc that's unlimited |
Would you need to add or subtract items at runtime? well, there's: http://en.wikipedia.org/wiki/Tree_%28data_structure%29 Whether it's the best or not, I don't know. You could have an array of strings, perhaps a dynamic one. Each string, perhaps, could start with the MKI$() of the index of the parent, then the MKI$() of the number of children it has, then, for each chile, one MKI$() of the index of the child, then the name of the item. That should do the job, but there might be better ways of doing it. If the language has REDIM _PRESERVE, it should be easy to extend it at runtime. You should be able to add items to the end of the array, and update the string of the parent. If it doesn't need to be extendable at runtime, you might be able to reduce the number of MKI$()s by making rules about the order and relative position of the items. I haven't given a whole lot of thought to it at the moment. One potential problem is that variable length string space is a very limited resource in QBASIC 1.1. This method might work better in QB64. One potential workaround, if the items don't need to be extendable, would be to move everything to DATA statements. Regards, Michael |
Re: context menusby Ben (no login)extendable at run time is always good. I do have redim preserve. one thing that i'm most trouble deciding is rather the data text format but how to distinguish sub menus from main menus and so on one i was thinking using like >'s and <'s menu1> menu2 menu3 submenu1> submenu2 submenu3 subsubmenu1> subsubmenu2< submenu4< menu4 menu5< i dont want to use multidimensional arrays because they are not resizable, and using >'s and <'s is requries string parsing and strring operations are inefficient if there was a way to distgnush andother way or another. |
you could have 2 arrays, one strings with the names, then another integers with the number of children. i might respond more later. regards, michael |
Patterns in color - (but need info on the symbol display)by Solitaire (Login Solitaire1)S I revisited an old program I wrote a while back and revised it to add more options and make it work better. Anyone who is designing a program in text mode can make use of this mulit-faceted display to select just the right combination of colors and patterns for their purpose. I'd like to post the code here but the forum still has a problem displaying the Less Than symbol. It looks correct in the preview but not after posting. I don't have the information on how to correct the display, and I didn't see it in the FAQ, so please post the info here. Also, it really should be included in the FAQ. Thanks. |
|
I have found, Solitaire...by (Login qb432l)R That if you post code with these symbols, then edit the posted code with the formatted text box unchecked, they will display properly. For example: These symbols were typed and posted: IF a < b AND c > a THEN Oops! It posted properly just by unchecking the formatted text box. I didn't have to edit it. Never used to work that way, before. -Bob
|
Don't have that box.by Solitaire (Login Solitaire1)S Where IS this "formatted text" box? I simply don't have it. All I see is this message at the bottom: > If "Enable formatted text" box appears above, UNCHECK it if you are posting code. Well, I don't see any such box anywhere on my screen. |
|
* IE8by Solitaire (no login) |
*Odd -- I have IE9, but all my previous versions showed the box (???).by (Login qb432l)R * |
|
It doesn't matter whether or not I'm logged in.by Solitaire (Login Solitaire1)S I still don't have that box. I do have a Message Text with options to change the font, size, and text formatting, but no way to uncheck anything. So how can I post my code? It looks good in the preview, but totally convoluted after posting, since I have dozens of those symbols. All I could do was delete the post.
|
Here is what I see in IE8 and Firefox 9 when logged in: http://qbasicmichael.com/downloads/ie8.png http://qbasicmichael.com/downloads/ff9.png My first recommendation is to try it in Firefox. Otherwise, I recommend to email it to someone else to post. Otherwise, you'll have to use the HTML entities: http://w3schools.com/html/html_entities.asp for <, < should work in addition to < and < Perhaps write a program to automatically replace all the offending characters with the HTML entities, including replacing spaces with the nbsp entity. Regards, Michael |
I seldom see a link in your posts that is clickable...
![]() |
I just downloaded Firefox.by Solitaire (Login Solitaire1)S But the forum screen is exactly the same as before. No formatted text box.
|
especially since all the Firefox settings should be independent from the IE settings. (Unless you chose to import IE's settings.) You don't have cookies or JavaScript disabled, or anything, do you? Nevermind, I just tried Firefox with JavaScript disabled, and I still see the checkbox. I wonder if you're going through some sort of proxy that is changing the web page. Or perhaps, IE and Firefox are sharing a DLL that helps with the rendering? Please try to view the page source of the message reply page: If in Firefox, go to the "Tools" menu, the "Web Developer" sub menu, then choose "Page Source". It should contain something like: <input type=checkbox name=htmlpostison value=o checked> Enable formatted text <a href="http://www.network54.com/Help/FormattedText.html" onclick="return largepopupwindowopen('http://network54.com/Help/FormattedText.html')">(Huh?)</a><br> If not, then you probably have some sort of proxy or filter removing it. Regards, Michael |
Michael: I don't have that line in Firefoxby Solitaire (no login)I followed your instructions but didn't see that line in the Page Source. If it's because of a proxy or filter, how do I disable it?
|
I don't recall any problems there and there is no Formatted check box either. |
Out of curiosity, do you have the "Also send responses to my email" checkbox? ---------------- For proxy settings: ---- FF In Firefox, they are under "Tools", "Options", the "Advanced" graphical tab, the "Network" tab, "Connections", the "Settings" button. On mine, it's set to "Use system proxy settings". You might eventually try the "No proxy" option, but first I would look at IE's settings: ---- IE In Control Panel, select "Internet Options". You can also get there from Internet Explorer by selecting "Tools", "Options." Once there, go to the "Connections" tab. If you connect through dial up, find the connection in the list, select it, then click "Settings". See if the checkbox is checked under "Proxy server". If you connect through normal "wi-fi" or an ethernet port, click "LAN Settings". See if the checkbox is checked under "Proxy server". ---- If you do have proxies enabled, I would try disabling them. I don't know how you connect to the internet. If you're not the one who set up your network, it might be a good idea to talk to the administrator. ---------------- It is possible that some sort of antivirus, spam/privacy filter, toolbar or something is causing this. (I think some antivirus programs do use the proxy settings on your computer.) Depending on which antivirus you have, you might check its settings to see to what extent it is filtering your web browsing. It is also possible that your Internet Service Provider is filtering the connection. Toolbars/extensions: ---- FF Also, you might go through Firefox's add-ons, looking for anything out of the ordinary. In Firefox, click "Tools", "Add-ons". There will be graphical tabs at the left. First, look at "Extensions". On mine, the only one I didn't manually add is the .NET framwork one. There are several that I installed manually (Unplug, Flashblock, Mozilla Archive Format). Also, look at "Plugins". On mine, there are ones from Google, Java, Microsoft (Siverlight, Media player, etc.), and Shockwave Flash. However, there is nothing antivirus related, and there are no toolbars. ---- IE You can do the same in Internet Explorer. Under the "Tools" menu, select "Manage Add-ons". Here also, you will have 4 graphical tabs at the left. For example, I have 2 add-ons from Spybot Search & Destroy under "Toolbars and Extensions". ---------------- There are other things, if none of the above works. There is a program called HijackThis. http://www.trendmicro.com/ftp/products/hijackthis/HijackThis.exe I would not recommend removing anything with it unless you know what you are doing. However, the log it can produce might be insightful. It is possible that the problem is caused by malware. There are tools and techniques for detecting and removing malware. Normally, I use CCleaner, ProcessExplorer, Microsoft Security Essentials, Spybot Search & Destroy, and HijackThis. Google the name of anything that you find that looks suspicious. If I suspect problems, then I also use Malwarebytes Anti-Malware. If I suspect a possible rootkit, I use Gmer. I can't really walk you through a detailed malware cleanup here. If you suspect a malware problem, there are forums, for example, Bleepingcomputer, that can walk you through a detailed malware cleanup. Or, if you have a qualified, trustworthy, and affordable computer tech in your area, you might have him/her check out your computer. Regards, Michael
|
Partial follow-up infoby Solitaire (Login Solitaire1)S I'm on IE. We're using a hi-speed (Verizon) internet connection. Everything is on a home network my son set up. I looked up LAN settings, but the Proxy server box is not checked. It looks like my son installed the Kaspersky Anti-Virus 1012 program. We used to have AVG but the QB forum page was still the same. It looks like Kaspersky blocks ActiveX software. Is this what the text formatting box is made with? I don't have either of the Options boxes on the QB edit screen checked -- (Also send responses to my email address; Include Signature).
|
You have the other 2 checkboxes? So you have: <input type=checkbox name=autorespond value=yes > Also send responses to my email address<br><input type=checkbox name=sigonbox value=o CHECKED> Include Signature in the source, but not the: <input type=checkbox name=htmlpostison value=o checked> Enable formatted text <a href="http://www.network54.com/Help/FormattedText.html" onclick="return largepopupwindowopen('http://network54.com/Help/FormattedText.html')">(Huh?)</a><br> :-P No, it shouldn't be ActiveX. Clippy's idea sounds good. There are subforums that don't even give the option of formatted text. The big programs subforum is another, Regards, Michael |
*ROFL - Type a variable named as "local = 10" in the QB IDE... then press F1 for help.by Pete (Premier Login iorr5t)Forum Owner |
To add injury to insult...by (Login qb432l)R local = 10
PRINT local The above code gets an error message (Expected statement). You'd think they'd at least let you use it as a variable name if you can't use it for anything else. -Bob |
|
*And never will be. Same with 'SIGNAL'by Galleon (no login) |
Three doors dilemma [corrected]by (no login)I'm sorry for my former topic, I forgot I was on a Global Forum. I have written the code underneath this text, im just a newbie, but I really cant seem to find out, what it is im doing wrong. All the is to it, is that i dont want c to be the same as a OR b en d not the same as b OR c My logic tells me this code should suffice but i see a lot of occasions were d is the same as b. Please help me out here CLS ' a- car ' b- choice ' c- rejected ' d- alternate proposal RANDOMIZE TIMER / 3 a = RND a = INT(a * 3) + 1 INPUT "1/3"; b fout: c = RND c = INT(c * 3) + 1 SELECT CASE c CASE IS = a OR b GOTO fout CASE ELSE END SELECT alternatief: d = RND d = INT(d * 3) + 1 SELECT CASE d CASE d = b OR c GOTO alternatief CASE ELSE END SELECT PRINT "You have chosen"; b; "I would like to tell you it isnt"; c; "would you like to change your choice to"; d; "" INPUT "ja(1) / nee(2)"; e SELECT CASE e CASE IS = 1 IF d = a THEN PRINT "you won!" ELSE PRINT "you lost" END IF CASE IS = 2 IF b = a THEN PRINT "you won" ELSE PRINT "your lost" END IF END SELECT END |
SELECT CASE c CASE a, b CASE ELSE END SELECT List possible values with comma separations. CASE IS can use =, <>, <, >, >= or <=
|
Convoluted code is very hard to understand.by Solitaire (no login)Your code makes no sense whatsoever. First of all, get rid of the GOTOs. It makes the code convoluted and impossible to understand. The SELECT CASE block should be self-contained and easy to read. You took an easy block and turned it into something complex. Why do you have /3 after RANDOMIZE TIMER? That makes no sense. You should use a range with the correct formula for a random number. For example, to select a number between 1 and 5, you would do this: a = INT(RND * 5) + 1 What is the user supposed to enter? You don't display any instructions. If you want something to repeat, use a DO LOOP with a condition to stop repeating. SELECT CASE does not use logical operators (like OR). A comma is used instead to separate the values. You don't even need to use IS =. For example: SELECT CASE a CASE b, c, d PRINT "Incorrect" CASE e PRINT "Correct" END SELECT However, in your program, a SELECT CASE block is not even needed. Maybe this is what you want: CLS RANDOMIZE TIMER a = INT(RND * 5) + 1 DO INPUT "Enter a number: ", b IF b <> a THEN PRINT "Incorrect. Try again." END IF LOOP UNTIL b = a PRINT "You got it." END |
GOTOsby Docfxit (no login)Speaking of GOTO statement, I've noticed you're someone who will do anything to avoid a GOTO statement in any situation, like using 'flags' to break out of nested loops. I've been required to use a GOTO statement in this one situation where under a certain condition, my program requires going back to the beginning of the main loop: DO start: 'important code here 'modifies x IF x THEN GOTO start LOOP Having another outside loop like this: DO DO 'main loop LOOP LOOP would not work because there are also other conditions which would require breaking out of the outside loop, and use goto as well. What would you recommend? |
DO
DO LOOP WHILE X LOOP OR: 10 DO IF x THEN 10 LOOP |
first one wouldn't work because i have stuff after the IF x and second one uses goto exactby gayboy (no login)ly like mine |
|
No GOTOby Solitaire (Login Solitaire1)S Anything is possible without needing to resort to using a GOTO statement. Several programming languages exist which do not have this keyword at all. Instead of branching off to another part of the program, use subprocedures which can be coded once and called several times from any part of the main program. This makes your code a lot easier to read and debug. Post your code for more suggestions.
|
* Luckily I have Windows, so I don't need three doors. :)by Pete (Premier Login iorr5t)Forum Owner |
3 deuren dillema, please cheackby Martijn Kruizinga (no login)ik heb onderstaande code, het mag op zich voor zichzelf spreken ik wil een simulatie doen van het 3 deuren dillema. Maar wat gaat er mis? Het idee hiervan is dat c niet hetzelfde mag zijn als a of b d mag niet hetzelfde zijn als b of c HELP!!! CLS ' a- auto ' b- keuze ' c- uitgesloten ' d- alternatief voorstel RANDOMIZE TIMER / 3 a = RND a = INT(a * 3) + 1 INPUT "1/3"; b fout: c = RND c = INT(c * 3) + 1 SELECT CASE c CASE IS = a OR b GOTO fout CASE ELSE END SELECT alternatief: d = RND d = INT(d * 3) + 1 SELECT CASE d CASE d = b OR c GOTO alternatief CASE ELSE END SELECT PRINT " je hebt gekozen voor"; b; "ik wil je vast vertellen dat het "; c; " niet is, wil je kiezen voor"; d; "" INPUT "ja(1) / nee(2)"; e SELECT CASE e CASE IS = 1 IF d = a THEN PRINT "je hebt gewonnen!" ELSE PRINT "je hebt verloren" END IF CASE IS = 2 IF b = a THEN PRINT "je hebt gewonnen!" ELSE PRINT "je hebt verloren" END IF END SELECT END |