Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hey Agamemnus!!!!
#31
The first error that I get is:

Expected: Expression at line 3 of the information sub.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#32
Because there isnt anything there for it to equal..But why does it say identifier cant contain a period..Thanks
Reply
#33
I really can't help you unless you actually post the code where all the info is there and where you are getting that error.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#34
Alright run this

Code:
DECLARE SUB Information ()
DECLARE SUB Sort ()
'DECLARE SUB Printing ()

DIM SHARED sort.item%
DIM SHARED entry.amount%
DIM SHARED gender.type$(1 TO 2)
DIM SHARED Nme$(1 TO 11)
DIM SHARED Address$(1 TO 11)
DIM SHARED Id(1 TO 11) AS LONG
DIM SHARED gender%(1 TO 11)
DIM SHARED Payrate(1 TO 11)

TYPE ClassRecord
Nme AS STRING * 15
Address AS STRING * 38
Id AS INTEGER
gender AS STRING * 6
Payrate AS SINGLE
END TYPE

DIM Info(1 TO 11) AS ClassRecord

CLS
PRINT "Choose how you want to sort the items!"
PRINT "--------------------------------------"
PRINT
PRINT "By name          Press 1"
PRINT "By address       Press 2"
PRINT "By id            Press 3"
PRINT "By gender        Press 4"
PRINT "By payrate       Press 5"
INPUT "Which do you want to sort by"; sort.item%
'PRINT
'PRINT "Type screen to print on screen, type printer to print from printer."
'PRINT "-------------------------------------------------------------------"
'INPUT "Do you want to print on screen or print on printer"; print$

gender.type$(1) = "Male"
gender.type$(2) = "Female"

CALL Information
CALL Sort
'CALL Printing

CLS

FOR i% = 1 TO 11
PRINT "Name: "; Nme$(i%);
SLEEP 1
PRINT " Address: "; Address$(i%)
PRINT "ID: "; Id(i%)
PRINT "Gender: "; gender.type$(gender%(i%))
PRINT "Hourly Salary: $"; Payrate(i%)
PRINT
NEXT i%

SUB Information

Info(i%).Nme$ = "Shane"
Info(i%).Nme$ = "Chris"
Nme$(3) = "Sean"
Nme$(4) = "Philip"
Nme$(5) = "Tim"
Nme$(6) = "Jeff"
Nme$(7) = "Austin"
Nme$(8) = "Justin"
Nme$(9) ="Colin"
Nme$(10) ="Rachel"
Nme$(11) ="Crystal"

Address$(1) = "1000 first street"
Address$(2) = "1001 first street"
Address$(3) = "1002 first street"
Address$(4) = "1003 first street"
Address$(5) = "1004 first street"
Address$(6) = "1005 first street"
Address$(7) = "1006 first street"
Address$(8) = "1007 first street"
Address$(9) = "1008 first street"
Address$(10) ="1009 first street"
Address$(11) ="1010 first street"

Id(1) = 444444
Id(2) = 222222
Id(3) = 333333
Id(4) = 999999
Id(5) = 777777
Id(6) = 666666
Id(7) = 555555
Id(8) = 111111
Id(9) = 000000
Id(10) = 545454
Id(11) = 121321

gender%(1) = 1
gender%(2) = 1
gender%(3) = 1
gender%(4) = 1
gender%(5) = 1
gender%(6) = 1
gender%(7) = 1
gender%(8) = 1
gender%(9) = 1
gender%(10) = 2
gender%(11) = 2

Payrate(1) = 6.3
Payrate(2) = 8.13
Payrate(3) = 8
Payrate(4) = 9.5
Payrate(5) = 7.35
Payrate(6) = 8.2
Payrate(7) = 6.95
Payrate(8) = 7.46
Payrate(9) = 6.25
Payrate(10) = 8.51
Payrate(11) = 6

END SUB

SUB Printing

'IF print$ = "Screen" OR print$ = "screen" THEN
    'FOR i% = 1 TO 11
    'PRINT "Name: "; name$(i%);
    'SLEEP 1
    'PRINT " Address: "; address$(i%)
    'PRINT "ID: "; id(i%)
    'PRINT "Gender: "; gender.type$(gender%(i%))
    'PRINT "Hourly Salary: $"; hourlysalary(i%)
    'PRINT
    'NEXT i%
'ELSE
    'FOR i% = 1 TO 11
    'LPRINT "Name: "; name$(i%);
    'SLEEP 1
    'LPRINT " Address: "; address$(i%)
    'LPRINT "ID: "; id(i%)
    'LPRINT "Gender: "; gender.type$(gender%(i%))
    'LPRINT "Hourly Salary: $"; hourlysalary(i%)
    'LPRINT
    'LPRINT
    'NEXT i%
'END IF

END SUB

SUB Sort

SELECT CASE sort.item%
CASE 1
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Nme$(j%) > Nme$(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 2
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Address$(j%) > Address$(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 3
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Id(j%) > Id(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 4
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF gender%(j%) > gender%(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%

CASE 5
    FOR i% = 1 TO 11
    FOR j% = 1 TO i%
    IF Payrate(j%) > Payrate(i%) THEN
    SWAP Nme$(j%), Nme$(i%)
    SWAP Address$(j%), Address$(i%)
    SWAP Id(j%), Id(i%)
    SWAP gender%(j%), gender%(i%)
    SWAP Payrate(j%), Payrate(i%)
    END IF
    NEXT j%, i%
END SELECT
END SUB
Reply
#35
You have to change this line:

Code:
DIM Info(1 TO 11) AS ClassRecord

into:

Code:
DIM SHARED Info(1 TO 11) AS ClassRecord

Else you won't be able to access it from the subroutine. It's just like you did before you implemented types.
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#36
Beware! That (1 TO 11) makes your access to arrays slower. It's better to work from 0 to 10, although it is less intuitive.

Code:
DIM array%(2 TO 12)

is slower than:

Code:
DIM array%(10)
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#37
Quote:It would be nice if.... someone... made a TYPE rewriter . . .

Why not ask for some preprocessor instructions giving OOP capabilities to QB, as Bjarne Stroustrup did for C?

This way could have QB++ !! :rotfl:
Antoni
Reply
#38
Well... if you give me a couple of years... lol Big Grin
Reply
#39
:|
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#40
Quote:Beware! That (1 TO 11) makes your access to arrays slower. It's better to work from 0 to 10, although it is less intuitive.

I know that, I was just using his own code to clearify it 8) .
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)