QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: badger on September 26, 2020, 03:41:06 pm
-
Hello
can someone tell me why this is happening
have _defstr s
TYPE customer
id AS LONG
sfirst_name AS STRING * 25
slast_name AS STRING * 25
saddress AS STRING * 30
scity AS STRING * 25
sstate AS STRING * 2
szip AS STRING * 5
sphone AS STRING * 10
END TYPE
DIM custinforec AS customer
s2: saction = "Enter Lase Name X to Exit - To Backup "
ib = 25
ilow = 99
ihigh = 99
iflag1 = 0
CALL salphainput(saction, ib, ilow, ihigh, iflag1)
IF saction = "-" THEN GOTO s1
IF saction = "X" THEN
RETURN
ELSE
LOCATE 11, 24
custinforec.sfirst_name=sr /the error is here/
PRINT custinforec.first_name
END IF
error is illaegal string-number conversion on line 287
-
Hi badger
from your stripped code I cannot see more...
but if I copy your code and paste it into QB64 IDE, after REMMED out the , and after type label and REMMED the C style commentI get no issue... so I can think that the line of code that rises up the error of illegal string number conversion is into a SUB or Function and not in the main or in a GOSUB.... in this case becomes a single variable...
but how to solve the question? Easy, make global shared the variable custinforec. How? Simply typing SHARED on the line of DIM custinforec... like this .
-
custinforec.sfirst_name
=sr
/the
error is here
/
So what is sr?
I can not duplicate the error unless sr = number.
I cannot set sr to number after DEFSTR S but before that I can.
-
If you got that right, without seeing the actual code where the error occurred, give yourself a prize!
To the OP: It's always best to post the entire code or at least all the code involved in the situation. For instance, if I had a program with 20 subs, but the error as only occurring in one of those subroutines, I'd copy the main, REM out the other sub calls, and copy that sub. Now, others could run the code, re-create the error, and hopefully enlighten me on why it didn't work correctly.
Now go in the kitchen and bake me a pizza. I might need it, to reward Tempo.
Pete
-
Hello
salphinput is an all in one input statement the only one the software will have
sr is the line input statement variable sr handles all input then transfers it value to the proper variable after it checks the validity of the info being entered . I will try your suggestions
Badger
-
Hello
Pete i think he gave me the answer but i have yet to try getting ready to. i use a lot of rem statement above each sub /label to help me keep track of my code, I have problems seeing so do this people dont like the way it looks.
Badger
if what i hope fixes it i will post all
-
Temopdibasic
Hello
I sorta thought it was something like that. I took out the type and just used the string veriables and all worked fine. I have not used subs in basic much even when i was using quick basic 4.5 i would recreate lables and gosub and goto them but from a common spot on in the problem.
Thanks very very much for the help
Badger
-
badger
Welcome in QB64 community...
when you have finished your program post your final work with code or a screenshot of your final well working program in the section of programs
-
...And don't forget, you owe Tempo a pizza!
Pete :D
-
Pete
That is fine with me LOL
Badger
-
I must affirm that half of the pizza is for Pete, so please ask him what kind of pizza does he like.
-
FREE PIZZA
-
I knew it! I saw that one coming LOL!