QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: badger on September 26, 2020, 03:41:06 pm

Title: illeagal string-number conversion error
Post 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
Title: Re: illeagal string-number conversion error
Post by: TempodiBasic on September 26, 2020, 04:38:17 pm
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
Code: QB64: [Select]
  1. CALL salphainput
, and after type
Code: QB64: [Select]
  1.  s1:
label  and REMMED the C style comment
Code: QB64: [Select]
  1.  /the error is here/
  2.  
I 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
Code: QB64: [Select]
  1. custinforec.sfirst_name
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
Code: QB64: [Select]
  1. DIM SHARED custinforec AS customer
.
Title: Re: illeagal string-number conversion error
Post by: bplus on September 26, 2020, 04:51:32 pm
Code: QB64: [Select]
  1. 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.
Title: Re: illeagal string-number conversion error
Post by: Pete on September 26, 2020, 04:53:39 pm
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
Title: Re: illeagal string-number conversion error
Post by: badger on September 26, 2020, 04:57:04 pm
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
Title: Re: illeagal string-number conversion error
Post by: badger on September 26, 2020, 05:00:30 pm
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

Title: Re: illeagal string-number conversion error
Post by: badger on September 26, 2020, 05:08:26 pm
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
Title: Re: illeagal string-number conversion error
Post by: TempodiBasic on September 27, 2020, 12:19:21 pm
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
Title: Re: illeagal string-number conversion error
Post by: Pete on September 27, 2020, 12:25:17 pm
...And don't forget, you owe Tempo a pizza!

Pete :D
Title: Re: illeagal string-number conversion error
Post by: badger on September 29, 2020, 10:54:05 am
Pete

That is fine with me LOL

Badger
Title: Re: illeagal string-number conversion error
Post by: TempodiBasic on September 29, 2020, 03:39:15 pm
I must affirm that half of the pizza is for Pete, so please ask him what kind of pizza does he like.
Title: Re: illeagal string-number conversion error
Post by: Pete on September 29, 2020, 08:46:23 pm
FREE PIZZA
Title: Re: illeagal string-number conversion error
Post by: bplus on September 29, 2020, 08:48:32 pm
I knew it! I saw that one coming LOL!