QBasic and QB64 Discussion Board

[QB Forum Archives (1999-2009)/ ] [QB FAQ] [QB Links and Downloads] [Subforums and Chat Room] [Search]

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$
PRINT
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





PRINT
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

Posted on Feb 1, 2012, 7:04 PM

Respond to this message   

Return to Index


It's been years since I've used QB, but I can comment on the algorithm(s).

by (Login ComputerGhost)
R

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).

Posted on Feb 1, 2012, 10:56 PM

Respond to this message   

Return to Index


*Thanks...I'll look into that

by (no login)

Posted on Feb 2, 2012, 1:13 PM

Respond to this message   

Return to Index


*Turing test (URL)

by (Login MCalkins)
Moderator

http://en.wikipedia.org/wiki/Turing_test

Posted on Feb 6, 2012, 12:49 AM

Respond to this message   

Return to Index


qb64 RUN keyword

by 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.

Posted on Feb 1, 2012, 10:38 AM

Respond to this message   

Return to Index


RUN was a command line word in Qbasic

by (Login burger2227)
R

QB64 cannot RUN a BAS file. It must compile it first into an EXE.

Posted on Feb 1, 2012, 4:01 PM

Respond to this message   

Return to Index


OK

by 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.

Posted on Feb 1, 2012, 4:56 PM

Respond to this message   

Return to Index


RUN is listed in Help after the QB64 keywords.

by (Login burger2227)
R

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





    
This message has been edited by burger2227 on Feb 1, 2012 5:57 PM

Posted on Feb 1, 2012, 5:56 PM

Respond to this message   

Return to Index


*there's a qb64help file?

by Ben (no login)

Posted on Feb 1, 2012, 7:22 PM

Respond to this message   

Return to Index


Re: *there's a qb64help file?

by lawgin (no login)

http://www.qb64.net/forum/index.php?topic=1362.0

Posted on Feb 2, 2012, 11:05 AM

Respond to this message   

Return to Index


Re: OK

by (Login MCalkins)
Moderator

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

Posted on Feb 1, 2012, 9:54 PM

Respond to this message   

Return to Index


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.

Posted on Jan 30, 2012, 11:14 PM

Respond to this message   

Return to Index


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



    
This message has been edited by qb432l on Jan 31, 2012 7:02 AM
This message has been edited by qb432l on Jan 31, 2012 7:00 AM

Posted on Jan 31, 2012, 6:51 AM

Respond to this message   

Return to Index


Compile it with QB64 and use ANY Windows screen capturing software.

by (Login burger2227)
R

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.



    
This message has been edited by burger2227 on Jan 31, 2012 1:01 PM

Posted on Jan 31, 2012, 12:59 PM

Respond to this message   

Return to Index


*Try "atube catcher"

by (no login)

Posted on Feb 1, 2012, 6:57 PM

Respond to this message   

Return to Index


RANDOMIZE question

by 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


Posted on Jan 30, 2012, 4:58 PM

Respond to this message   

Return to Index


Because the next 3 numbers are a continuation of the sequence

by (Login burger2227)
R

QB64 allows you to restart a sequence with USING:

RANDOMIZE 100
PRINT RND, RND, RND
n = 100
RANDOMIZE USING n
PRINT RND, RND, RND

Posted on Jan 30, 2012, 5:16 PM

Respond to this message   

Return to Index


Good tip, thanks

by lawgin (no login)

I thought another RANDOMIZE restarted the sequence, but not so.

Posted on Jan 30, 2012, 5:35 PM

Respond to this message   

Return to Index


Need help with text encoding program

by (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
PRINT
setKey
encodeKey
PRINT "'"; k; "'"
PRINT "'"; Key$; "'"
PRINT "Your Encryption Key is : "; EncryptionKey$
PRINT
LINE INPUT "Enter Message : "; message$
encode
PRINT
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

Posted on Jan 28, 2012, 3:43 PM

Respond to this message   

Return to Index


Looks like a mistype

by 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.

Posted on Jan 28, 2012, 5:37 PM

Respond to this message   

Return to Index


*Thanks.. i would've never caught that.. lol

by (no login)

Posted on Jan 28, 2012, 8:19 PM

Respond to this message   

Return to Index


You can shorten those CASE statements

by (no login)

Posted on Jan 28, 2012, 8:21 PM

Respond to this message   

Return to Index


*How?

by (no login)

Posted on Jan 29, 2012, 8:53 AM

Respond to this message   

Return to Index


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



    
This message has been edited by qb432l on Jan 29, 2012 10:27 AM

Posted on Jan 29, 2012, 10:19 AM

Respond to this message   

Return to Index


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
PRINT
setKey
encodeKey
PRINT "'"; k; "'"
PRINT "'"; Key$; "'"
PRINT "Your Encryption Key is : "; EncryptionKey$
PRINT
LINE INPUT "Enter Message : "; message$
encode
PRINT
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

Posted on Jan 29, 2012, 11:01 AM

Respond to this message   

Return to Index


*Thanks, I'll try that

by (no login)

Posted on Jan 29, 2012, 12:47 PM

Respond to this message   

Return to Index


for example

by (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))

Posted on Jan 29, 2012, 5:47 PM

Respond to this message   

Return to Index


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.

Posted on Jan 29, 2012, 7:36 PM

Respond to this message   

Return to Index


Using ASCII values to reverse or shift encryption

by 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
DIM first AS INTEGER, last AS INTEGER
DIM message AS STRING, letter AS STRING
DIM newmassage AS STRING, newletter AS STRING
CLS
PRINT "Type your message in English."
PRINT "The message will be translated into a secret code."
PRINT : PRINT "Enter your message on the next line:"
PRINT : LINE INPUT "", message$
PRINT : PRINT "Your coded message is as follows:"
N = LEN(message$)     'Reverse order of keyboard characters ASCII values
FOR x = 1 TO N
    V = 0
    letter$ = MID$(message$, x, 1)
    letter$ = LCASE$(letter$)
    IF letter$ >= CHR$(32) AND letter$ [=  CHR$(126) THEN

       first = 32: last = 126
    END IF
    FOR R = first TO last
        IF letter$ = CHR$(R) THEN
            newletter$ = CHR$(last - V)
            EXIT FOR
        END IF
        V = V + 1
    NEXT R
    newmessage$ = newmessage$ + newletter$
NEXT x
PRINT : PRINT newmessage$
END

===============================================================================================

DECLARE FUNCTION decode$ (coded AS STRING)
DECLARE FUNCTION code$ (message AS STRING, ikey AS INTEGER)
DIM message AS STRING, saved AS STRING, E AS STRING, skey AS STRING
DIM ikey AS INTEGER, secret AS STRING
DO
    CLS : PRINT , "CODER - DECODER"
    PRINT , "Choose one from the menu:"
    PRINT : PRINT
    PRINT "1 - Select a key number"
    PRINT "2 - Enter a new message"
    PRINT "3 - Retrieve a saved message"
    PRINT "4 - Decrypt a message"
    PRINT "5 - Quit"
    PRINT
    INPUT "Enter your choice:  ", ch$
    SELECT CASE ch$
        CASE "1"
            DO
                CLS
                PRINT "Select a key number between 1 - 92 ";
                PRINT "or press Enter or 0 for a random key."
                PRINT "Random key will be selected when you enter a new message."
                PRINT "Key will stay in effect until a new number is selected."
                PRINT : PRINT "The current key number is"; ikey
                PRINT : INPUT "Enter new key number:  ", skey$
                ikey = VAL(skey$)
                IF ikey  [= 0 OR ikey > 92 THEN
                    PRINT "Wrong key number.  Please reenter."
                END IF
            LOOP UNTIL ikey >= 0 AND ikey  [ 93

        CASE "2"
            CLS
            IF ikey = 0 THEN
                RANDOMIZE TIMER
                ikey = INT(RND * 92) + 1
            END IF
            PRINT : PRINT "Type your message in English on one line:"
            PRINT : PRINT
            LINE INPUT "", message$
            saved$ = message$
            PRINT : PRINT "Your coded message is as follows:"
            secret$ = code$(message$, ikey)
            savecode$ = secret$
            PRINT : PRINT
            PRINT secret$
            PRINT : INPUT "Enter to return to the menu: ", E$
        CASE "3"
            CLS : PRINT "Your saved message was:"
            PRINT : PRINT
            PRINT saved$
            PRINT : INPUT "Enter to return to the menu: ", E$
        CASE "4"
            CLS
            PRINT "Type your encrypted message or Enter to retrieve code:"
            PRINT : LINE INPUT "", coded$
            IF coded$ = "" THEN
                coded$ = secret$
                PRINT : PRINT secret$
            END IF
            IF secret$ = "" THEN
                PRINT "No encrypted message exists."
            ELSE
                PRINT : PRINT "Your decoded message is as follows:"
                revealed$ = decode$(coded$)
                PRINT : PRINT
                PRINT revealed$
            END IF
            PRINT : INPUT "Enter to return to the menu: ", E$
        CASE "5"
            CLS
            END
    END SELECT
LOOP
END

FUNCTION code$ (message AS STRING, ikey AS INTEGER)
DIM n AS INTEGER, x AS INTEGER, codenum AS INTEGER, a AS STRING
DIM letter AS STRING, codeletter AS STRING, hexkey AS STRING
n = LEN(message$)
FOR x = 1 TO n        'Shift ASCII values to the right by ikey value
    letter$ = MID$(message$, x, 1)
    codenum = ASC(letter$) + ikey
    IF codenum > 126 THEN
        codenum = codenum - 93
    END IF
    codeletter$ = CHR$(codenum)
    secret$ = secret$ + codeletter$
NEXT x
hexkey$ = HEX$(ikey)   'last 2 characters are added with key # as hex
IF LEN(hexkey$) = 1 THEN hexkey$ = "0" + hexkey$
code$ = secret$ + hexkey$
END FUNCTION

FUNCTION decode$ (coded AS STRING)
DIM n AS INTEGER, x AS INTEGER, codenum AS INTEGER, a AS STRING
DIM letter AS STRING, codeletter AS STRING
ikey = VAL(RIGHT$(coded$, 2))   'translates last 2 characters from hex
n = LEN(coded$) - 2
coded$ = LEFT$(coded$, n)
FOR x = 1 TO n        'Shift ASCII values to the left by ikey value
    letter$ = MID$(coded$, x, 1)
    codenum = ASC(letter$) - ikey
    IF codenum         codenum = codenum + 93
    END IF
    letter$ = CHR$(codenum)
    revealed$ = revealed$ + letter$
NEXT x
decode$ = revealed$
END FUNCTION

 



    
This message has been edited by Solitaire1 on Jan 29, 2012 7:43 PM
This message has been edited by Solitaire1 on Jan 29, 2012 7:16 PM
This message has been edited by Solitaire1 on Jan 29, 2012 6:48 PM

Posted on Jan 29, 2012, 4:23 PM

Respond to this message   

Return to Index


*Thanks.. what does LTRIM$ do?

by (no login)

Posted on Jan 29, 2012, 6:23 PM

Respond to this message   

Return to Index


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$. 



    
This message has been edited by Solitaire1 on Jan 29, 2012 6:53 PM

Posted on Jan 29, 2012, 6:46 PM

Respond to this message   

Return to Index


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
skey$ = LTRIM$(STR$(ikey))
RANDOMIZE TIMER
a$ = CHR$(INT(RND * 26) + 97)
IF LEN(skey$) = 1 THEN skey$ = skey$ + a$
code$ = secret$ + skey$
END FUNCTION

I replaced it with:

NEXT x
hexkey$ = HEX$(ikey)   'last 2 characters are added with key # as hex
IF LEN(hexkey$) = 1 THEN hexkey$ = "0" + hexkey$
code$ = secret$ + hexkey$
END FUNCTION

 

 

 



    
This message has been edited by Solitaire1 on Jan 29, 2012 7:32 PM

Posted on Jan 29, 2012, 7:29 PM

Respond to this message   

Return to Index


*oh...Ok...Thanks

by (no login)

Posted on Jan 30, 2012, 2:55 PM

Respond to this message   

Return to Index


splitting a screen vertically

by (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?

Posted on Jan 26, 2012, 9:50 AM

Respond to this message   

Return to Index


Is this what you meant?

by (Login MCalkins)
Moderator

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

Posted on Jan 26, 2012, 3:12 PM

Respond to this message   

Return to Index


qb64

by (no login)

qb64 would involve _putimage and just a simple text scrolling routine. i'd use qb64 to do it.

Posted on Jan 26, 2012, 11:50 PM

Respond to this message   

Return to Index


thanks

by (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.

Posted on Jan 28, 2012, 8:36 AM

Respond to this message   

Return to Index


*yw.

by (Login MCalkins)
Moderator

Posted on Feb 6, 2012, 12:56 AM

Respond to this message   

Return to Index


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 :)

Posted on Jan 24, 2012, 1:56 PM

Respond to this message   

Return to Index


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.

Posted on Jan 24, 2012, 3:08 PM

Respond to this message   

Return to Index


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.

Posted on Jan 24, 2012, 7:27 PM

Respond to this message   

Return to Index


Ok

by Zack (no login)

Ok thanks, I guess Ill just have to figure out whats different between the two and recreate it.

Posted on Jan 25, 2012, 11:46 AM

Respond to this message   

Return to Index


Re: Ok

by (Login MCalkins)
Moderator

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.



    
This message has been edited by MCalkins on Jan 25, 2012 8:53 PM

Posted on Jan 25, 2012, 8:49 PM

Respond to this message   

Return to Index


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.

Posted on Jan 21, 2012, 3:21 PM

Respond to this message   

Return to Index


Before a sprite moves, check for the wall

by (Login burger2227)
R

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.

Posted on Jan 21, 2012, 6:25 PM

Respond to this message   

Return to Index


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.

Posted on Jan 21, 2012, 8:24 PM

Respond to this message   

Return to Index


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



    
This message has been edited by qb432l on Jan 21, 2012 8:50 PM
This message has been edited by qb432l on Jan 21, 2012 8:49 PM
This message has been edited by qb432l on Jan 21, 2012 8:46 PM
This message has been edited by qb432l on Jan 21, 2012 8:43 PM

Posted on Jan 21, 2012, 8:42 PM

Respond to this message   

Return to Index


Tell the enemy where you are

by (Login burger2227)
R

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.

Posted on Jan 21, 2012, 8:53 PM

Respond to this message   

Return to Index


it could get trapped

by 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

Posted on Jan 21, 2012, 10:17 PM

Respond to this message   

Return to Index


Going towards a different approach

by 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

Posted on Jan 22, 2012, 4:05 PM

Respond to this message   

Return to Index


Re: Going towards a different approach

by Rick4551 (no login)

Never mind I found the problem but thanks for the help. :)

Posted on Jan 23, 2012, 5:59 PM

Respond to this message   

Return to Index


Move It -- Just for fun

by 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
ch$ = CHR$(1)
a = 4
LOCATE 1, 30
PRINT "Move Across"
FOR x = 2 TO 80 STEP 2
    COLOR 14
    LOCATE 4, a
    PRINT " "
    LOCATE 4, x
    PRINT ch$
    a = x
    t = TIMER
    DO WHILE (t + .12) >= TIMER
    LOOP
NEXT x
COLOR 7
LOCATE 2, 30
PRINT "Move Down    "

FOR x = 2 TO 23
    COLOR 14
    LOCATE x - 1, 4
    PRINT " "
    LOCATE x, 4
    PRINT ch$
    t = TIMER
    DO WHILE (t + .12) >= TIMER
    LOOP
NEXT x
COLOR 7

LOCATE 3, 30
PRINT "Move Diagonally"
a = 2
b = 2
FOR x = 2 TO 20
    COLOR 14
    y = x
    z = x * 4
    LOCATE a, b
    PRINT " "
    LOCATE y, z
    PRINT ch$
    a = y
    b = z
    t = TIMER
    DO WHILE (t + .12) >= TIMER
    LOOP
NEXT x
br = 9    'begin row
er = 15   'end row
bc = 32   'begin column
ec = 42   'end column
LOCATE br, bc
PRINT CHR$(218); STRING$(9, CHR$(196)); CHR$(191)
FOR x = br + 1 TO er
    LOCATE x, bc: PRINT CHR$(179)
    LOCATE x, ec: PRINT CHR$(179)
NEXT x
LOCATE x, bc
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

 

 



    
This message has been edited by Solitaire1 on Jan 18, 2012 8:10 PM
This message has been edited by Solitaire1 on Jan 18, 2012 7:58 PM
This message has been edited by Solitaire1 on Jan 17, 2012 4:37 PM

Posted on Jan 17, 2012, 3:20 PM

Respond to this message   

Return to Index


Cute!

by (Login burger2227)
R

Thanks for sharing...I know how you feel.

wink.gif

Posted on Jan 17, 2012, 8:48 PM

Respond to this message   

Return to Index


Solitaire, I love your programs

by 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



    
This message has been edited by Solitaire1 on Jan 18, 2012 8:11 PM
This message has been edited by Solitaire1 on Jan 18, 2012 7:59 PM

Posted on Jan 17, 2012, 8:52 PM

Respond to this message   

Return to Index


Interesting revision

by 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.



    
This message has been edited by Solitaire1 on Jan 18, 2012 8:13 PM

Posted on Jan 18, 2012, 8:07 PM

Respond to this message   

Return to Index


*LOL - I get "moves faster than I can". My back went out recently, lasted two weeks.

by (Login qb432l)
R

*

Posted on Jan 17, 2012, 10:44 PM

Respond to this message   

Return to Index


Colors and Patterns -- with link to a subforum for the code

by 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!


http://www.network54.com/Forum/190883/message/1326005896/Colors+and+Patterns

 

Posted on Jan 7, 2012, 11:11 PM

Respond to this message   

Return to Index


*Nice work -- lots of fun exploring the myriad combinations.

by (Login qb432l)
R

*



    
This message has been edited by qb432l on Jan 8, 2012 2:01 AM

Posted on Jan 8, 2012, 1:59 AM

Respond to this message   

Return to Index


(edited)

by (Login MCalkins)
Moderator

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



    
This message has been edited by MCalkins on Jan 8, 2012 2:41 PM
This message has been edited by MCalkins on Jan 8, 2012 2:41 PM

Posted on Jan 8, 2012, 2:10 PM

Respond to this message   

Return to Index


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.

 



    
This message has been edited by Solitaire1 on Jan 8, 2012 4:38 PM

Posted on Jan 8, 2012, 4:35 PM

Respond to this message   

Return to Index


Re: Is it really needed?

by (Login MCalkins)
Moderator

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

Posted on Jan 9, 2012, 5:53 PM

Respond to this message   

Return to Index


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.



Posted on Jan 9, 2012, 6:21 PM

Respond to this message   

Return to Index


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.



    
This message has been edited by Solitaire1 on Jan 9, 2012 10:09 PM
This message has been edited by Solitaire1 on Jan 9, 2012 9:53 PM

Posted on Jan 9, 2012, 9:44 PM

Respond to this message   

Return to Index


context menus

by Ben (no login)

what would be a good data structure to store content for sub menus & sub sub sub... menus etc that's unlimited

Posted on Jan 7, 2012, 8:42 PM

Respond to this message   

Return to Index


Re: context menus

by (Login MCalkins)
Moderator

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

Posted on Jan 8, 2012, 1:53 PM

Respond to this message   

Return to Index


Re: context menus

by 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.

Posted on Jan 8, 2012, 4:21 PM

Respond to this message   

Return to Index


Re: context menus

by (Login MCalkins)
Moderator

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

Posted on Jan 8, 2012, 9:57 PM

Respond to this message   

Return to Index


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.

Posted on Jan 5, 2012, 3:07 PM

Respond to this message   

Return to Index


* Doesn't un-checking the Formatted text box help?

by (Login burger2227)
R

Posted on Jan 5, 2012, 3:16 PM

Respond to this message   

Return to Index


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



    
This message has been edited by qb432l on Jan 5, 2012 4:00 PM
This message has been edited by qb432l on Jan 5, 2012 3:59 PM

Posted on Jan 5, 2012, 3:58 PM

Respond to this message   

Return to Index


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.

Posted on Jan 5, 2012, 4:27 PM

Respond to this message   

Return to Index


* ODD, what browser?

by (Login burger2227)
R

Posted on Jan 5, 2012, 5:26 PM

Respond to this message   

Return to Index


* IE8

by Solitaire (no login)

Posted on Jan 5, 2012, 5:41 PM

Respond to this message   

Return to Index


*Odd -- I have IE9, but all my previous versions showed the box (???).

by (Login qb432l)
R

*

Posted on Jan 5, 2012, 5:46 PM

Respond to this message   

Return to Index


* ARRGH, you have to log in to get the box!

by (Login burger2227)
R

Posted on Jan 5, 2012, 6:35 PM

Respond to this message   

Return to Index


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.

 

 

Posted on Jan 5, 2012, 10:18 PM

Respond to this message   

Return to Index


Re: It doesn't matter whether or not I'm logged in.

by (Login MCalkins)
Moderator

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 <, &#x3c; should work in addition to &lt; and &#60;

Perhaps write a program to automatically replace all the offending characters with the HTML entities, including replacing spaces with the nbsp entity.

Regards,
Michael

Posted on Jan 6, 2012, 1:02 AM

Respond to this message   

Return to Index


Use Chrome! Michael you must always uncheck the box!

by (Login burger2227)
R

I seldom see a link in your posts that is clickable...

wink.gif

Posted on Jan 6, 2012, 8:12 AM

Respond to this message   

Return to Index


I just downloaded Firefox.

by Solitaire (Login Solitaire1)
S

But the forum screen is exactly the same as before.  No formatted text box.

 

Posted on Jan 6, 2012, 1:32 PM

Respond to this message   

Return to Index


That's odd

by (Login MCalkins)
Moderator

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

Posted on Jan 6, 2012, 3:36 PM

Respond to this message   

Return to Index


Michael: I don't have that line in Firefox

by 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?



    
This message has been edited by Solitaire1 on Jan 7, 2012 11:56 AM

Posted on Jan 7, 2012, 11:55 AM

Respond to this message   

Return to Index


Why not just post in in Proud Of Forum and post link here?

by (Login burger2227)
R

I don't recall any problems there and there is no Formatted check box either.

Posted on Jan 7, 2012, 1:56 PM

Respond to this message   

Return to Index


I'm going out on a limb.

by (Login MCalkins)
Moderator

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



    
This message has been edited by MCalkins on Jan 7, 2012 2:24 PM
This message has been edited by MCalkins on Jan 7, 2012 2:22 PM
This message has been edited by MCalkins on Jan 7, 2012 2:20 PM

Posted on Jan 7, 2012, 2:19 PM

Respond to this message   

Return to Index


Partial follow-up info

by 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).

 

Posted on Jan 7, 2012, 4:46 PM

Respond to this message   

Return to Index


Re: Partial follow-up info

by (Login MCalkins)
Moderator

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

Posted on Jan 7, 2012, 5:55 PM

Respond to this message   

Return to Index


*ROFL - Type a variable named as "local = 10" in the QB IDE... then press F1 for help.

by Pete (Premier Login iorr5t)
Forum Owner

Posted on Jan 4, 2012, 6:48 PM

Respond to this message   

Return to Index


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

Posted on Jan 5, 2012, 3:57 AM

Respond to this message   

Return to Index


* At least it isn't reserved in QB64...yet...

by (Login burger2227)
R

Posted on Jan 5, 2012, 7:46 AM

Respond to this message   

Return to Index


*And never will be. Same with 'SIGNAL'

by Galleon (no login)

Posted on Jan 5, 2012, 1:28 PM

Respond to this message   

Return to Index


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

Posted on Jan 4, 2012, 2:03 PM

Respond to this message   

Return to Index


Don't use OR in SELECT CASE

by (Login burger2227)
R

SELECT CASE c
CASE a, b
CASE ELSE
END SELECT

List possible values with comma separations.

CASE IS can use =, <>, <, >, >= or <=



    
This message has been edited by burger2227 on Jan 4, 2012 3:25 PM
This message has been edited by burger2227 on Jan 4, 2012 3:24 PM

Posted on Jan 4, 2012, 3:23 PM

Respond to this message   

Return to Index


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

Posted on Jan 4, 2012, 6:00 PM

Respond to this message   

Return to Index


GOTOs

by 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?

Posted on Jan 4, 2012, 8:32 PM

Respond to this message   

Return to Index


2 loops

by (Login burger2227)
R

DO
DO

LOOP WHILE X

LOOP

OR:

10
DO

IF x THEN 10

LOOP

Posted on Jan 4, 2012, 10:46 PM

Respond to this message   

Return to Index


first one wouldn't work because i have stuff after the IF x and second one uses goto exact

by gayboy (no login)

ly like mine

Posted on Jan 5, 2012, 12:09 AM

Respond to this message   

Return to Index


* IF doesn't need GOTO for line numbers

by (Login burger2227)
R

Posted on Jan 5, 2012, 9:22 AM

Respond to this message   

Return to Index


No GOTO

by 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.



    
This message has been edited by Solitaire1 on Jan 5, 2012 9:16 AM

Posted on Jan 5, 2012, 9:13 AM

Respond to this message   

Return to Index


* Luckily I have Windows, so I don't need three doors. :)

by Pete (Premier Login iorr5t)
Forum Owner

Posted on Jan 4, 2012, 6:50 PM

Respond to this message   

Return to Index


3 deuren dillema, please cheack

by 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

Posted on Jan 4, 2012, 1:57 PM

Respond to this message   

Return to Index