Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please Help Me
#21
read it....

You didn't define your variables in the same way as you used them, most likely. If you use id%(), you need to say DIM SHARED id%(1 to 11), not DIM SHARED Grid$(1 TO 11, 1 TO 5).

Show me your current code.
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
#22
Yea nevermind i know where it goes....i just wanna know one last thing....What does the i% and j% and all that stuff actually mean and the & sign after hourlysalary
Reply
#23
Um, well "&" is like "%", except it means LONG, which gives you -1.4billion to 1.4 billion, instead of -32k to 32k . I think salaries can go over 32K, can't they? Smile

And the i and j go with the sort technique:

1) You loop through each value in the array.
2) You loop through the values before it. j%=(1 to i%-1)
3) If the previous value is larger than the current value, you swap them. This way, you will keep swapping until the i%th value is in its spot..
4) You keep doing it until you're done.
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
#24
Alright....Having a lil more trouble....Here it is:

DECLARE SUB Information ()
DECLARE SUB Sort ()
DECLARE SUB Display ()

DIM SHARED grid$(1 TO 11, 1 TO 5)
DIM SHARED grid.name$(1 TO grid.length%), grid.address$(1 TO grid.length%), grid.id%(1 TO grid.length%), grid.gender%(1 TO grid.length%), grid.hourlysalary&(1 TO grid.length%)
DIM SHARED gender.type$(1 TO 2)


CALL Information
CALL Sort
CALL Display

SUB Display

grid.length% = 5
DIM SHARED grid.name$(1 TO grid.length%), grid.address$(1 TO grid.length%), grid.id%(1 TO grid.length%), grid.gender%(1 TO grid.length%), grid.hourlysalary&(1 TO grid.length%)
DIM SHARED gender.type$(1 TO 2)

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

FOR i% = 1 TO grid.length%
PRINT grid.name$(i%)
PRINT grid.address$(i%)
PRINT grid.id%(i%)
PRINT gender.type$(grid.gender%(i%))
PRINT grid.hourlysalary&(i%)
NEXT i%




'NEXT
'PRINT
'NEXT
END SUB

SUB Information

CLS
FOR row = 1 TO 5
FOR col = 1 TO 11

grid$(1, 1) =
grid$(1, 2) =
grid$(1, 3) =
grid$(1, 4) =
grid$(1, 5) =

grid$(2, 1) =
grid$(2, 2) =
grid$(2, 3) =
grid$(2, 4) =
grid$(2, 5) =

grid$(3, 1) =
grid$(3, 2) =
grid$(3, 3) =
grid$(3, 4) =
grid$(3, 5) =

grid$(4, 1) =
grid$(4, 2) =
grid$(4, 3) =
grid$(4, 4) =
grid$(4, 5) =

grid$(5, 1) =
grid$(5, 2) =
grid$(5, 3) =
grid$(5, 4) =
grid$(5, 5) =

grid$(6, 1) =
grid$(6, 2) =
grid$(6, 3) =
grid$(6, 4) =
grid$(6, 5) =

grid$(7, 1) =
grid$(7, 2) =
grid$(7, 3) =
grid$(7, 4) =
grid$(7, 5) =

grid$(8, 1) =
grid$(8, 2) =
grid$(8, 3) =
grid$(8, 4) =
grid$(8, 5) =

grid$(9, 1) =
grid$(9, 2) =
grid$(9, 3) =
grid$(9, 4) =
grid$(9, 5) =

grid$(10, 1) =
grid$(10, 2) =
grid$(10, 3) =
grid$(10, 4) =
grid$(10, 5) =

grid$(11, 1) =
grid$(11, 2) =
grid$(11, 3) =
grid$(11, 4) =
grid$(11, 5) =
NEXT
NEXT

END SUB

SUB Sort

FOR i% = 1 TO 11
FOR j% = 1 TO i% - 1
IF name$(j%) > names(i%) THEN
SWAP names$(j%), names$(i%)
SWAP address$(j%), address$(i%)
SWAP id(j%), id(i%)
SWAP gender(j%), gender(i%)
SWAP hourlysalary(j%), hourlysalary(i%)
END IF
NEXT j$, i%

END SUB
Reply
#25
Think logically. AND USE THE CODE TAGS! (at the top of the message box..)

You're repeating your DIM statements in your display sub. You should have the stuff in your display sub in the main portion of the program.

You're calling your subs before you actually create your variables.

You don't have any data in your variables in your information sub.

Your information sub is loading stuff into your grid$() array, but it needs to load it into 5 different arrays.

Your sort routine's variables are different than the variables you are dimming.

In your sort routine, you make a typo again: "NEXT j$, i%"
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
#26
Oh....Im just totally confused....I have no clue what im doing....Please help....
Reply
#27
Code:
DECLARE SUB load.info ()
DECLARE SUB sort ()
DECLARE SUB display ()
DECLARE SUB query ()

DIM SHARED sort.item%
DIM SHARED entry.amount%
DIM SHARED gender.type$(1 TO 2)
entry.amount% = 5
DIM SHARED name$(1 TO entry.amount%)
DIM SHARED address$(1 TO entry.amount%)
DIM SHARED id(1 TO entry.amount%) AS INTEGER
DIM SHARED gender(1 TO entry.amount%) AS INTEGER
DIM SHARED hourlysalary(1 TO entry.amount%) AS DOUBLE

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

load.info
query
sort
display

CLS
FOR i% = 1 TO entry.amount%
PRINT "Name: "; name$(i%);
PRINT " | Address: "; address$(i%);
PRINT " | ID:"; id%(i%);
PRINT "| Gender: "; gender.type$(gender%(i%))
PRINT "Hourly Salary: "; hourlysalary(i%)
PRINT
NEXT i%


SUB load.info
name$(1) = "Bob"
name$(2) = "Mike"
name$(3) = "Ronald McDonald"
name$(4) = "Evil man"
name$(5) = "Alice"

address$(1) = "1 Normal Way"
address$(2) = "10 Normal Way"
address$(3) = "7 McDonald's Street"
address$(4) = "32 Bombed Cave Street"
address$(5) = "64 Wonderland Avenue"

id%(1) = 3563
id%(2) = 1
id%(3) = 68
id%(4) = 1000
id%(5) = 0

gender%(1) = 1
gender%(2) = 1
gender%(3) = 1
gender%(4) = 1
gender%(5) = 2

hourlysalary(1) = 17.5
hourlysalary(2) = 27.5
hourlysalary(3) = 400.25
hourlysalary(4) = 0
hourlysalary(5) = 6.75
END SUB

SUB query
CLS
INPUT "Sort on name (1), address (2), id (3), gender (4), or hourly salary? (5)"; sort.item%
END SUB

SUB sort
SELECT CASE sort.item%
CASE 1
FOR i% = 1 TO entry.amount%
FOR j% = 1 TO i% - 1
IF name$(j%) > name$(i%) THEN
SWAP name$(j%), name$(i%)
SWAP address$(j%), address$(i%)
SWAP id(j%), id(i%)
SWAP gender(j%), gender(i%)
SWAP hourlysalary(j%), hourlysalary(i%)
END IF
NEXT j%, i%

CASE 2
FOR i% = 1 TO entry.amount%
FOR j% = 1 TO i% - 1
IF address$(j%) > address$(i%) THEN
SWAP name$(j%), name$(i%)
SWAP address$(j%), address$(i%)
SWAP id(j%), id(i%)
SWAP gender(j%), gender(i%)
SWAP hourlysalary(j%), hourlysalary(i%)
END IF
NEXT j%, i%

CASE 3
FOR i% = 1 TO entry.amount%
FOR j% = 1 TO i% - 1
IF id(j%) > id(i%) THEN
SWAP name$(j%), name$(i%)
SWAP address$(j%), address$(i%)
SWAP id(j%), id(i%)
SWAP gender(j%), gender(i%)
SWAP hourlysalary(j%), hourlysalary(i%)
END IF
NEXT j%, i%

CASE 4
FOR i% = 1 TO entry.amount%
FOR j% = 1 TO i% - 1
IF gender(j%) > gender(i%) THEN
SWAP name$(j%), name$(i%)
SWAP address$(j%), address$(i%)
SWAP id(j%), id(i%)
SWAP gender(j%), gender(i%)
SWAP hourlysalary(j%), hourlysalary(i%)
END IF
NEXT j%, i%

CASE 5
FOR i% = 1 TO entry.amount%
FOR j% = 1 TO i% - 1
IF hourlysalary(j%) > hourlysalary(i%) THEN
SWAP name$(j%), name$(i%)
SWAP address$(j%), address$(i%)
SWAP id(j%), id(i%)
SWAP gender(j%), gender(i%)
SWAP hourlysalary(j%), hourlysalary(i%)
END IF
NEXT j%, i%
END SELECT
END 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
#28
Ok....Thanx man....But can u explain this stuff to me so i can understand
Reply
#29
I did explain it. You need to read things with more attention.
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
#30
Sorry....Where did u explain it at....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)