Search |
 |
|
 |
| Author |
Message |
|
|
Posted: Mar 12, 2012 - 01:53 AM |
|


Joined: Dec 11, 2007
Posts: 6854
Location: Cleveland, OH
|
|
|
Quote:
substr(1) = RIGHT(substr(1), len(substr(1)) - 2)
I've not tsted it, but I'd hazzard a guess:
There are very few instructions in Bascom that can accept multi-part calculations within an expression.
This means that one should have a single variable in the len() command, not a calculated value.
X = substr(1)-2
y = len(x)
might work for you.
Additionally, you would have to be sure that the value (length) was >= 0.
The same is true for math expressions, only one calculation permitted on a line.
JC |
|
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 07:26 AM |
|


Joined: Sep 19, 2005
Posts: 765
Location: Belgium
|
|
|
Quote:
The same is true for math expressions, only one calculation permitted on a line.
I'm astounded people still choose this development environment.
So you are saying it should be done as follows ? :
Code:
Dim ti as integer
ti = len(substr(1))
ti = ti - 2
substr(1) = RIGHT(substr(1), ti)
|
|
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 11:23 AM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
To read your positions, i have written an interface program to return those values to the computer/Hamlib when it receives the string:
"AZ EL \n"
from Hamlib. That string is sent to the interface when the 'p' command is types to rotctl. When your interface receives that string it should respond with:
"AZaaa.a ELeee.e"
where aaa.a and eee.e are the decimal degrees to a single decimal place.
problem i am facing is I can read the position of the rotator in my terminal window, but i am unable to to return them to the hamlib (command window).
_____________________________________________________
Dim Akey As Byte , S As String * 80 , Azimuth As Integer , Elevation As Integer , Substr(5) As String * 10 , Bcount As Byte , J As Byte
Dim W1 As Word , A As Single , C As Single , W2 As Word , A1 As Single , C1 As Single ,
Do
S = ""
Do
Akey = Waitkey()
If Akey = 13 Then Goto Thanks
S = S + Chr(akey)
Loop
Thanks:
Print "Rotctl values " ; S
Bcount = Split(s , Substr(1) , " ")
For J = 1 To Bcount
Next
If Substr(1) = "SA" Then
Porta = 0
Elseif S = "!" Then
W1 = Getadc(3)
A = W1 + 0.6613
C = A / 2.1867
W2 = Getadc(7)
Locate 2 , 1
A1 = W2 + 33.21
C1 = A1 / 6.261
Print "AZ" ; C ; " " ; "EL" ; C1 'this value should be returned to command window
Else
Dim T1 As Integer , T2 As Integer
T1 = Len(substr(1))
T1 = T1 - 2
T2 = Len(substr(2))
T2 = T2 - 2
Substr(1) = Right(substr(1) , T1)
Substr(2) = Right(substr(2) , T2)
' convert strings to numeric values
Azimuth = Val(substr(1)) : Print Azimuth
Elevation = Val(substr(2)) : Print Elevation
If Azimuth > 45 Then
Porta.0 = 1
Porta.1 = 1
Porta.2 = 0
Else
Print "no operation "
End If
End If
Loop
End |
|
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 05:43 PM |
|


Joined: Sep 19, 2005
Posts: 765
Location: Belgium
|
|
|
Code:
T1 = Len(substr(1))
T1 = T1 - 2
T2 = Len(substr(2))
T2 = T2 - 2
Substr(1) = Right(substr(1) , T1)
Substr(2) = Right(substr(2) , T2)
So I take it this works then ?
I see the PC app sends "!" only, without CR or LF, so your loop to read a line until CR will not exit after receiving this.
So put another rule in that loop to jump to another label when an exclamation mark has been received. |
|
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 06:03 PM |
|

Joined: Aug 14, 2011
Posts: 135
|
|
yes sir its works.
I have one dough in one of the previous post you have said me to use
"if Akey =10 then goto" instead of
"if Akey = 13 then goto"
by looking at the string in the command window which was "a"
my question is for "a" ascii key value is "099" but "10" is for LF(Line feed) |
_________________ Thanking You
Mahaveer
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 06:15 PM |
|


Joined: Sep 19, 2005
Posts: 765
Location: Belgium
|
|
take a look at that screenshot again.
I never said the character was "a", the hexadecimal value of the last character was 0x0A, which is LineFeed.
There is no printable character for LF, so the ASCII display to the right of the hex display shows a "." for that character, as is usual for all hex editors.
 |
Last edited by thygate on Mar 12, 2012 - 07:41 PM; edited 2 times in total
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 06:16 PM |
|


Joined: Mar 27, 2002
Posts: 18585
Location: Lund, Sweden
|
|
|
Quote:
my question is for "a" ascii key value is "099" but "10" is for LF(Line feed)
1. I don't see the question in there,
2. Yes, LineFeed is CHR(10),
3. No, an "a" is 97 (not 99) (I told you this a page back or so).
Points 2 and 3 should also be absolutely clear after inspection of the Wikipedia article on ASCII. There is a very nice table about halfway down with all printable characters and their ASCII values (in binary, octal, decimal and hex to boot!). Please read. |
|
|
| |
|
|
|
|
|
Posted: Mar 12, 2012 - 08:07 PM |
|


Joined: Jul 18, 2005
Posts: 62354
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
There is a very nice table about halfway down
The irony is that a similar table exists in the manual page for ASC() in the Bascom user manual. But, hey, who reads manuals any more eh? (even after I've posted 3 or 4 links to this thread) |
_________________
|
| |
|
|
|
|
|
|
|
|