Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Unexpected Behavior with pointers (Where to report bugs?)


Carli Jun 9, 2017 07:10 AM

 I am currently trying to write a program that uses pointers created from variable names.

The following program is working as expected.

Public USA1_Val As Float
Public USA2_Val As Float
Public USA3_Val As Float
Public USARet_Val As Long
Public USAVal As Float
Public USAStr As String * 32
Public USAStr2 As String * 32
Public USAStr3 As String * 32 BeginProg USA1_Val=1111 USA2_Val=2222 USA3_Val=3333 USAStr="USA1" Scan (1,Sec,0,0)
' Generate the variable name USAStr2=USAStr & "_Val"
' Create pointer to variable name USARet_Val = @(USAStr2) ' Read the value of variable name
USAVal = !USARet_Val
' Get the variable name by pointer value USAStr3 = !(USARet_Val) NextScan EndProg

 Unfortunatly trying to remove the USAStr2, replacing:

    USARet_Val = @(USAStr2)

with

    USARet_Val = @(USAStr & "_Val")

will lead to not to the expected behavior. USARet_Val will result to -2.147.483.648 and not a valid address pointer.

Where to report this bug?

PS: I would like to mention that the help for Pointer Values is stating wrongly that with Name=(!)X the name of a variable can be received. The correct syntax is Name=!(X). Also the help does not mention that with @(StringThatContainsVariableName) a pointer can be initalized! I just found out about this in this thread.

CR1000
Compiler: C:\Program Files (x86)\Campbellsci\LoggerNet\Lib\Compilers\CR1Comp.exe
Version: CR1000.Std.31.03 CompileDate: 04/14/2017 (Used also on the Logger itself)
DefFile: C:\Program Files (x86)\Campbellsci\LoggerNet\Lib\CRBasicDefFiles\CR1000.def
HelpFile: C:\Program Files (x86)\Campbellsci\LoggerNet\Lib\CRBasicDefFiles\CRBasic1.chm

CR Basic Editor 3.6 Build 3,6,0,14

Log in or register to post/reply in the forum.