Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
dim test1 as single = 1.0
dim test2 as single = 1.0
dim test3 as single = 1.0
dim test4 as single = 1.0
dim returnVar as single
returnVar = 1.0 * ( 1.0 * (test1 + test2) + 1.0 * (test3 + test4) )
why might I get the error "Expected end-of-line following value expression"?
EDIT: turns out this has to be in the context of the function, as anything in the last two lines--including the addition shown above--will yield that error.
Commenting out either of the last two lines results in compilation.
Reducing the complexity of one of the lines results in compilation; eg.
public function findCM(byval mode as byte, byref returnVar1 as single, byref returnVar2 as single) as byte
dim xkneeL as single, ykneeL as single
dim xthighCML as single, ythighCML as single
dim xshankCML as single, yshankCML as single
dim xkneeR as single, ykneeR as single
dim xthighCMR as single, ythighCMR as single
dim xshankCMR as single, yshankCMR as single
xthighCML = thighCMdist*sin(DEG_TO_RAD*thighAngle(Lleg))
ythighCML = -thighCMdist*cos(DEG_TO_RAD*thighAngle(Lleg))
xkneeL = 2.0*xthighCML
ykneeL = 2.0*ythighCML
xshankCML = xkneeL + shankCMdist*sin(DEG_TO_RAD*(thighAngle(Lleg) + kneeAngle(Lleg)))
yshankCML = ykneeL - shankCMdist*cos(DEG_TO_RAD*(thighAngle(Lleg) + kneeAngle(Lleg)))
xthighCMR = thighCMdist*sin(DEG_TO_RAD*thighAngle(Rleg))
ythighCMR = -thighCMdist*cos(DEG_TO_RAD*thighAngle(Rleg))
xkneeR = 2.0*xthighCMR
ykneeR = 2.0*ythighCMR
xshankCMR = xkneeR + shankCMdist*sin(DEG_TO_RAD*(thighAngle(Rleg) + kneeAngle(Rleg)))
yshankCMR = ykneeR - shankCMdist*cos(DEG_TO_RAD*(thighAngle(Rleg) + kneeAngle(Rleg)))
returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass * (xshankCML + xshankCMR) )
returnVar2 = one_over_systemMass * ( thighMass * (ythighCML + ythighCMR) + shankMass * (yshankCML + yshankCMR) )
end function
Last edited by pjc30943 on 22 August 2008, 15:25 PM, edited 1 time in total.
Apparently, there's more context that is needed to reveal the problem. It compiles fine here if I add some missing constant and array definitions. Could you send me the full source code?
Also, which version of the compiler are you using?
dkinzer wrote:Apparently, there's more context that is needed to reveal the problem. It compiles fine here if I add some missing constant and array definitions. Could you send me the full source code?
Also, which version of the compiler are you using?
2.5.5
The following complete code exhibits the error.
It is a nonsensical test case that uses nonititialized vars, etc..
If either of the last two lines are commented out, the program compiles.
If, for example, the 2nd to last line is simplified to be
'demonstrates a problem where one of two lines in the findCM function cause a compilation error.
'----------- Configurations ---------\\
Option TargetCPU zx1280n
Option ExtRamConfig On
Option PortPinEncoding Off
Option TaskStackMargin 12
'~ Option RamSize 64*1024-Register.RamStart
'~ Option HeapSize 500
public tickPerS as single 'holds main clock frequency
public SPerTick as single '1 / tickPerS
public three60_over_tickPerS as single
'-------------------------------------//
'-------------------------------------
public const thighLen as single = 46.0 'cm from joint to joint of upper leg
public const shankLen as single = 43.0 'lower leg
public const thighMass as single = 2.0 'in kg
public const shankMass as single = 2.0
public const bodyMass as single = 1.0
public const systemMass as single = 2.0 * (thighMass + shankMass) + bodyMass 'total mass of the biped
public const one_over_systemMass as single = 1.0 / systemMass
'-------------------------------------
Sub Main()
End Sub
public function findCM(byval mode as byte, byref returnVar1 as single, byref returnVar2 as single) as byte
dim xkneeL as single, ykneeL as single
dim xthighCML as single, ythighCML as single
dim xshankCML as single, yshankCML as single
dim xkneeR as single, ykneeR as single
dim xthighCMR as single, ythighCMR as single
dim xshankCMR as single, yshankCMR as single
returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass * (xshankCML + xshankCMR) )
returnVar2 = one_over_systemMass * ( thighMass * (ythighCML + ythighCMR) + shankMass * (yshankCML + yshankCMR) )
end function
pjc30943 wrote:why might I get the error "Expected end-of-line following value expression"?
It turns out that the line beginning with returnVar1 = had an end-of-line consisting of a carriage return only. The current release of the ZBasic compiler's parser does not handle this EOL style; it replaces a lone carriage return with a space thus causing the confusion. The ZBasic IDE handles the old Macintosh end-of-line correctly so there is no visual indication of what the problem might be.
The compiler has now been modified to handle all three end-of-line combinations: CR only, LF only, and CR-LF (previously, only two of the three were supported). This should be available in the next public release.