Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - Zum C-Control-I-Forum - Zum C-Control-II-Forum

Re: Indices Kategorie: Programmierung Basic (von Laurens - 29.01.2013 19:13)
Als Antwort auf Re: Indices von PeterS - 28.01.2013 19:23
Ich nutze:
C-Control Pro Mega128, Pro-Bot128
> > Hi,
> >
> > I am trying to get information from my GPS receiver but the progrm gives this fault:
> > C:UsersLaurensDesktopC-controlDingenGPS 1.0GPS 1.0.cbas(16,5): Semantic Error
> > - array variable strGLL must have1 indices
> > What does this mean? And how can I resolve it?
> >
> > I have another question, how do I get the lattitude and longtitude out of the GLL since it looks like this:
> > $GPGLL,3723.2475,N,12158.3416,W,161229.487,A*2C
> >
> >
> > Dim strGLL(47) As Char                 'Example $GPGLL,3723.2475,N,12158.3416,W,161229.487,A*2C
> >
> > Sub Main()
> >
> >     Serial_Init(0,SR_8BIT Or SR_1STOP Or SR_NO_PAR,SR_BD4800)
> >     GETGPS()
> >
> > End Sub
> >
> > Sub GETGPS()
> >
> >     Dim strINPUT(28) As Char
> >     strINPUT = "$PSRF103,01,01,00,01*24,0D0A"
> >     Serial_WriteText(0,strINPUT)
> >     AbsDelay(2000)
> >     strGLL = Serial_Read(0)
> >
> > End Sub
> >
> > Sub LATTITUDE()
> >
> >     Dim strLAT(9) As Char
> >     strLAT = Split(strGLL, ".")
> >
> > End Sub
> >

> >
> > With kind regards
> > Laurens
>
> There are 3 problems:
>
> 1.) strINPUT is too small, since the string must be terminated
> with a null char
> 2.) You have not defined a function Split()
> 3.) strGLL is an array variable. Since Serial_Read(0)
> gives back one character, you must write strGLL(i) = Serial_Read(0)
>
> It looks like that you should consult the demo programs first, to get
> some impression how to work with the BASIC.
>
> Regards,
>
> Peter
>

Thanks for your reply.
I've been looking for a split that works but couldn't find one so I tried to do it another way:

Sub LATTITUDE()

    Dim LAT As Integer
    Str_WriteInt(0000000,strGLL,0)
    Str_WriteInt(0000000000000000000000000000000,strGLL,17)
    LAT = Str_ReadNum(strGLL,4)

End Sub

I didn't try it out though.

Regard,
Laurens


    Antwort schreiben


Antworten: