Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

<solved> Read string chr(26) : compiler reports an err

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Thu Jun 28, 2012 2:28 pm    Post subject: <solved> Read string chr(26) : compiler reports an err Reply with quote

Hi folks,

I was implementing a Help-file in my program and used <ctrl>Z as End-Of-File-marker. But the Bascom-compiler reports an error: Error : 42 Line : 74 Numeric parameter expected [CHR(26)]
I fixed it by using the string "End of Help-file" as EOF-marker, and testing on that in the While - Wend. That works fine, so I don't have a hot issue.

But I found it peculiar enough to report it here. IMO Chr(26) is very stringy Wink

Cheers

Nard

Code:
'Demo to show compiler error-message when string-read reads chr(26)
'Bascom 2.0.7.3-001

Const Comm_speed = 19200

'For normal operation: set both to 1
Const Soft_uart_out = 1
Const Soft_uart_in = 1

$regfile = "M328pdef.dat"
$crystal = 20000000
$baud = 19200

$hwstack = 50
$swstack = 40
$framesize = 40

'For terminal on USB connection:
#if Soft_uart_out = 1
'Terminal on USB
Open "comd.4:19200,8,n,1" For Output As #4                  'soft UART for output on PortD.4
#endif
#if Soft_uart_in = 1
'Terminal on USB
Open "comd.7:19200,8,n,1" For Input As #3                   'soft UART for input on PortD.7
#endif

Dim Help_page_line As String * 100                          'that should be enough Wink

'Print Help-page to terminal
Restore Help_file                                           'label
Read Help_page_line
'While Help_page_line <> "End of Help-file"                  'keep reading and printing until that string is found
While Help_page_line <> Chr(26)
'<ctrl>Z as End-Of-File-marker would have been nice, but the Bascom-compiler reports an error:
'Error : 42    Line :   74    Numeric parameter expected [CHR(26)]  , in File : D:\Voyager\AVR Werkmap\read_string1.bas
   Print #4 , Help_page_line
Read Help_page_line
Wend

Do
loop


$data

Help_file:
Data "Terminate a request or command with a <CR>, no <LF>"
Data ""
Data "ID of MySingleLabSupply is 2; for MyDualLabSupply: ID=1 for left, ID=2 for right side"

Data " -----------------------------------------"
Data "| Requests and Commands for the ISO PSU's |"
Data " -----------------------------------------"
Data "Requests:"
Data "Start with the Id of the ISO PSU, followed by"
Data " V   Give the output Voltage in mV (also valid when output is disconnected)"
Data " A   Give the output Current in mA"
Data " S   Give Status"
Data " O   Give Overload status (current)"
Data "         (0 = no overload, any higher (max=Cool means overload)"
Data " l   (lower case L) Give the set current overLoad value"
Data "         (now 0 - 255 in rev 0x, will be 0-6400 in rev1x, in mA, 10mA steps)"
Data " T   Give Temperature (highest of heatsinks) in degr Celsius"
Data " m   Give currently selected power mode:"
Data "        Q  Quiet"
Data "        M  SMPS pre-regulating by MC34063 or LT1074"
Data "Example: 2V<CR> gives you the outputvoltage in mV"
Data ""
Data "Plons, June 2012"
Data ""
Data "End of Help-file"
Data Chr(26)

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"


Last edited by Plons on Thu Jun 28, 2012 5:03 pm; edited 1 time in total
Back to top
View user's profile
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 299
Location: Berlin

germany.gif
PostPosted: Thu Jun 28, 2012 3:55 pm    Post subject: Reply with quote

don't use chr(26) in datalines, use

Code:
Data "{026}"


which inserts a ctrl-z
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Thu Jun 28, 2012 5:02 pm    Post subject: Reply with quote

That works fine indeed !
Thank you for your help.

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum