FAQ  •  Register  •  Login

A big D on my hat

<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Feb 18, 2014 9:43 am

A big D on my hat

How do I do,

  Code:
dim a$(3)
for f=1to 3
read a$(f)
data "text1","text2","text3"
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Feb 18, 2014 9:51 am

Re: A big D on my hat

ardentcrest wrote:How do I do,

  Code:
dim a$(3)
for f=1to 3
read a$(f)
data "text1","text2","text3"

At the moment, ZX BASIC does not support read, data.
You have to do:
  Code:
a$(1) = "text1"
a$(2) = "text2"
...

If you need to reset a$ from time to time, put it in a subroutine.
Note: Support for READ, DATA and RESTORE is planned (for backward compatibility).
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Feb 18, 2014 9:55 am

Re: A big D on my hat

Thanks
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Feb 18, 2014 11:15 am

Re: A big D on my hat

temp.bor:16: identifier 'v$' is a var, not an array


  Code:
dim v$(10)

v$(1)="n"
v$(2)="s"
v$(3)="e"
v$(4)="w"


:|
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Feb 18, 2014 12:14 pm

Re: A big D on my hat

ardentcrest wrote:
temp.bor:16: identifier 'v$' is a var, not an array


  Code:
dim v$(10)

v$(1)="n"
v$(2)="s"
v$(3)="e"
v$(4)="w"


:|

This seems a bug I've recently fixed. Can you check you have the latest version? (1.4.0s1860)
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Feb 18, 2014 12:29 pm

Re: A big D on my hat

mine 1.4.0-s1860

remember I'm using borIDE
I'm always on the chat or facebook.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Feb 18, 2014 12:43 pm

Re: A big D on my hat

Damn it!
I forgot to upload the fix! :shock: And the packing script is in a machine 2500km away from me :oops: :lol:
Will try to upload the new version tonight.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Tue Feb 18, 2014 12:45 pm

Re: A big D on my hat

:evil: :evil: :evil: :evil: :arrow: :roll:
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Wed Feb 19, 2014 9:33 am

Re: A big D on my hat

  Code:
for i=1 to len(q$)-1
if q$(1 to i)=" " and x$="" then let x$=q$( 1 to i-1)
next i


input.bas:38: warning: Empty loop

works if I remove the if line but still give empty loop warning


OK need to add end if but nothing appears in the x$
I'm always on the chat or facebook.
<<

ardentcrest

Posts: 94

Joined: Fri Oct 11, 2013 5:19 pm

Post Wed Feb 19, 2014 3:23 pm

Re: A big D on my hat

got it :)

I have to learn basic all over again, not just for the spectrum but for the compiler :evil:
I'm always on the chat or facebook.
<<

dbolli

Posts: 1

Joined: Tue Feb 10, 2015 11:54 am

Post Tue Feb 10, 2015 12:00 pm

Re: A big D on my hat

Try this for an interim solution

  Code:
#include "read-data-restore.bas"

SETDATAVALUES( @TESTDATA1 )

WHILE ( NOT DataValuesEndFlag )
    PRINT READDATA() ': PRINT
END WHILE

PAUSE 0

SETDATAVALUES( @TESTDATA2 )

DIM Duration as Float
DIM Pitch as Byte

WHILE ( NOT DataValuesEndFlag )
    Duration = VAL( READDATA() )
    Pitch = VAL( READDATA() )
    BEEP Duration, Pitch
END WHILE

STOP

TESTDATA1:

ASM

DEFM "String1,"
DEFM "string2,"
DEFM "string3,"
DEFM "string4,string5,string6,string7,string8,string9"
DEFB $00          ; Terminating byte

END ASM

TESTDATA2:

ASM

; Frere Gustav
DEFM "1,0,1,2,.5,3,.5,2,1,0,"
DEFM "1,0,1,2,.5,3,.5,2,1,0,"
DEFM "1,3,1,5,2,7,"
DEFM "1,3,1,5,2,7,"
DEFM ".75,7,.25,8,.5,7,.5,5,.5,3,.5,2,1,0,"
DEFM ".75,7,.25,8,.5,7,.5,5,.5,3,.5,2,1,0,"
DEFM "1,0,1,-5,2,0,"
DEFM "1,0,1,-5,2,0"
DEFB $00

END ASM


--- read-data-restore.bas

' Basic implementation of DATA, READ and RESTORE functionailty
' :dbolli:20150209 19:48:23

DIM DataValuesPointer AS UInteger = 0
DIM CurrentDataValuesPointer AS UInteger = 0
DIM DataValuesEndFlag AS Byte = 0
DIM DataSeperator AS UByte = CODE( "," )

SUB SETDATAVALUES ( DataStringPointer AS UInteger )

    LET DataValuesPointer = DataStringPointer
    LET CurrentDataValuesPointer = DataStringPointer
    LET DataValuesEndFlag = 0

END SUB

FUNCTION READDATA AS String

    IF ( ( CurrentDataValuesPointer <> DataValuesPointer ) AND ( PEEK( UByte, CurrentDataValuesPointer - 1 ) = $00 ) ) THEN

ASM

        RST $08
        DEFB $0D                ; Report E - Out of DATA error message

END ASM

    ELSE

        DIM DataReturnString AS String
        DIM DataByte AS UByte

        LET DataReturnString = ""

        WHILE ( 1 )

            DataByte = PEEK( UByte, CurrentDataValuesPointer )

            LET CurrentDataValuesPointer = CurrentDataValuesPointer + 1

            IF ( ( DataByte = DataSeperator ) OR ( DataByte = $00 ) ) THEN

                EXIT WHILE

            ELSE

                LET DataReturnString = DataReturnString + CHR( DataByte )

            END IF

        END WHILE

        LET DataValuesEndFlag = ( DataByte = $00 )

        RETURN DataReturnString

    END IF

END FUNCTION

SUB RESTOREDATAVALUES

    LET CurrentDataValuesPointer = DataValuesPointer
    LET DataValuesEndFlag = 0

END SUB



Regards,
Derek.

Return to Help & Support

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO