![]() |
Forum Index : Microcontroller and PC projects : passing a value
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
I am having a problem with some code something=6 anything$="something" anything$ now = something Is there a way to get the value 6 back from anything$ I looked at "Passing Arguments by Reference" but didn't really understand. Hope I explaided it OK Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
StoveMan Regular Member ![]() Joined: 29/03/2013 Location: United StatesPosts: 51 |
Something=6 anything$=Str$(something) 'get my six something_back=val(anything$) will that work? |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Is something an integer? IE anything$=Str$(something,1,0) (Single digit only). and >Print Val(Anything$) 6 > Or am I on the wrong tangent. Phil. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
anything$="something" The value of the string anything$ is text. The fact that it looks the same as the variable called 'something' is not of any use. Until now! PRINT EVAL(anything$) I think it's only on the MM+ Jim VK7JH MMedit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Thanks anything$ must continue to hold the string something I then want to assign the value of something to another variable by only using anything $ I am using MM+ so will look into Jim's answer Thanks all Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
@ TassyJim Where did you find the EVAL() function I have looked in the latest version of both manuals and can't find it. I will try it anyway Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
StoveMan Regular Member ![]() Joined: 29/03/2013 Location: United StatesPosts: 51 |
to convert number string to real number... only good if you have validated the string to contain just numerals. anything$="12345" For A=1 to Len(anything$) Digit=Val(mid$(anything$,A,1)) something_new = something_new *10 + Digit Next A something=something_new To fold a longer number into a string just use format something=12345 anything$=Format$(something,"%g") ' string will expand to include each digit. g modifier just says use 'best guess format'. other conversions are possible if you know you have fractional numbers |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
Micromite Plus manual. V5.3 beta 10 page 53 VK7JH MMedit |
||||
StoveMan Regular Member ![]() Joined: 29/03/2013 Location: United StatesPosts: 51 |
@ tassyjim: will eval work thus? I thought it was for passing say an equation and then could be "evaluated' to produce a calculated value. how would I use it to convert string to decimal equivalent. It would seem much easier than my current method! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
VK7JH MMedit |
||||
StoveMan Regular Member ![]() Joined: 29/03/2013 Location: United StatesPosts: 51 |
COOL! thanks just assumed it would fail ![]() |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Something wrong here, I just downloaded the manuals again from Geoff's web site and got V5.2 manuals. Will have another look. Maybe the manual will be in the V5.3 download folder. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
OK finally found the manuals, they are not on Geoff's web site yet as they are still in beta. There will be a slight delay now until I reflash the micro. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Hey Paul, If you download the 5.3 Beta 10, linked in Geoff post, the manuals will be inside the zip file. Can't not credit Geoff on the quality of his manuals. Nothing short of excellent. Cheers Phil. |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Still having problems. the function EVAL works OK. But in the for/next loop where the strings are evaluated I get an error "Error: Expression syntax". but the syntax is OK the code actually loops twice OK before displaying the error. The project. At our little Golf Club (70 members) they run a Footy Tipping Comp. I thought it would be fun to enter a Micromite in the comp. so I am endeavouring to write some code to do just that. The idea being that teams will be given a value based on performance and then compared against one another to make a selection. The years draw is in DATA and the current week is selected from that. I still have to do the RESULTS part yet but am just trying to get this going. For a start the teams have been allocated a number related to their performance last year. The code so far: '**************************************************************************************** 'AFL Tipping Paul Cahill Dec.2016 '**************************************************************************************** VAR restore If week > 1 Then GoTo start week = 1 'Setup VAR save week Sydney = 18 'Setup Geelong = 17 Hawthorn = 16 GWS = 15 Adelaide = 14 WCE = 13 WesternBulldogs = 12 NorthMelbourne = 11 StKilda = 10 PtAdelaide = 9 Melbourne = 8 Collingwood = 7 Richmond = 6 Carlton = 5 GoldCoast = 4 Fremantle = 3 Brisbane = 2 Essendon = 1 VAR save Sydney,Geelong,Hawthorn,GWS,Adelaide,WCE,WesternBulldogs,NorthMelbourne,StKilda VAR save PtAdelaide,Melbourne,Collingwood,Richmond,Carlton,GoldCoast,Fremantle,Brisbane,Essendon START: Dim teamhome$(10) Dim teamaway$(10) Dim Sel$(10) games = 9 Do Read round 'some rounds have less than 9 games If round = 9 Then games = 8 If round = 11 Then games = 6 If round = 12 Then games = 7 If round = 13 Then games = 6 For x = 1 To games ' load the draw for the current week Read teamhome$(x) Read teamaway$(x) Next x Loop Until round = week Print "ROUND " week For z = 1 To games Print teamhome$(z)" v. "teamaway$(z) Next z Selections ' Sub selections For i = 1 To games Print Sel$(i) Next i week = week + 1 VAR save week:End Data 1,"Carlton","Richmond","Collingwood","Western Bulldogs","StKilda","Melbourne","Sydney","Pt Adelaide","Brisbane","Gold Coast" Data "Essendon","Hawthorn","North Melbourne","WCE","Adelaide","GWS","Fremantle","Geelong",2,"Richmond","Collingwood" Data "Western Bulldogs","Sydney","Hawthorn","Adelaide","GWS","Gold Coast","Brisbane","Essendon","West Coast","StKilda" Data "Geelong","North Melbourne","Melbourne","Carlton","Pt Adelaide","Fremantle",3,"Sydney","Collingwood","North Melbourne" Data "GWS","Richmond","WCE","Geelong","Melbourne","Adelaide","Pt Adelaide","Fremantle","Western Bulldogs" Data "StKilda","Brisbane","Carlton","Essendon","Gold Coast","Hawthorn",4,"WCE","Sydney","North Melbourne","Western Bulldogs","Melbourne" Data "Fremantle","GWS","Pt Adelaide","Carlton","Gold Coast","Adelaide","Essendon","Collingwood","StKilda","Brisbane" Data "Richmond","Hawthorn","Geelong",5,"Pt Adelaide","Carlton","Western Bulldogs","Brisbane","Gold Coast","Adelaide","Sydney" Data "GWS","Fremantle","North Melbourne","StKilda","Geelong","Hawthorn","WCE","Richmond","Melbourne","Essendon","Collingwood" Data 6,"GWS","Western Bulldogs","Hawthorn","StKilda","Carlton","Sydney","Brisbane","Pt Adelaide","North Melbourne" Data "Gold Coast","WCE","Fremantle","Essendon","Melbourne","Geelong","Collingwood","Adelaide","Richmond",7,"StKilda","GWS" Data "North Melbourne","Adelaide","Collingwood","Carlton","Pt Adelaide","WCE","Gold Coast","Geelong","Western Bulldogs","Richmond","Sydney" Data "Brisbane","Melbourne","Hawthorn","Fremantle","Essendon",8,"WCE","Western Bulldogs","Hawthorn","Brisbane","StKilda","Carlton" Data "GWS","Collingwood","Essendon","Geelong","Adelaide","Melbourne","Richmond","Fremantle","Gold Coast","Pt Adelaide" Data "North Melbourne","Sydney",9,"Geelong","Western Bulldogs","StKilda","Sydney","GWS","Richmond","Brisbane","Adelaide" Data "Collingwood","Hawthorn","Essendon","WCE","Melbourne","North Melbourne","Fremantle","Carlton",10,"Geelong","Pt Adelaide","Sydney","Hawthorn" Data "Western Bulldogs","StKilda","Melbourne","Gold Coast","Richmond","Essendon","Adelaide","Fremantle","Collingwood","Brisbane","Carlton" Data "North Melbourne","WCE","GWS",11,"Pt Adelaide","Hawthorn","Geelong","Adelaide","Gold Coast","WCE","GWS" Data "Essendon","North Melbourne","Richmond","Fremantle","Collingwood",12,"Sydney","Western Bulldogs","Adelaide","StKilda","Hawthorn","Gold Coast" Data "Brisbane","Fremantle","Essendon","Pt Adelaide","Carlton","GWS","Melbourne","Collingwood",13,"WCE","Geelong","North Melbourne" Data "StKilda","Richmond","Sydney","Pt Adelaide","Brisbane","Gold Coast","Carlton","Western Bulldogs","Melbourne",14,"Adelaide","Hawthorn","Sydney" Data "Essendon","Collingwood","Pt Adelaide","Brisbane","GWS","Western Bulldogs","North Melbourne","WCE","Melbourne","Geelong" Data "Fremantle","Richmond","Carlton","StKilda","Gold Coast",15,"Melbourne","Sydney","Western Bulldogs","WCE","Carlton","Adelaide","Gold Coast" Data "North Melbourne","GWS","Geelong","Pt Adelaide","Richmond","Essendon","Brisbane","Hawthorn","Collingwood","Fremantle" Data "StKilda",16,"Adelaide","Western Bulldogs","Hawthorn","GWS","Collingwood","Essendon","Sydney","Gold Coast","Brisbane","Geelong" Data "StKilda","Richmond","North Melbourne","Fremantle","Carlton","Melbourne","WCE","Pt Adelaide",17,"StKilda","Essendon","Geelong","Hawthorn" Data "Pt Adelaide","North Melbourne","Gold Coast","Collingwood","GWS","Sydney","Melbourne","Adelaide","Richmond","Brisbane" Data "Carlton","Western Bulldogs","Fremantle","WCE",18,"Adelaide","Geelong","Essendon","North Melbourne","Melbourne","Pt Adelaide","Western Bulldogs" Data "Gold Coast","Sydney","StKilda","Fremantle","Hawthorn","Richmond","GWS","Collingwood","WCE","Brisbane","Carlton",19,"Hawthorn" Data "Sydney","North Melbourne","Melbourne","GWS","Fremantle","Pt Adelaide","StKilda","Carlton","Geelong","Gold Coast","Richmond" Data "Western Bulldogs","Essendon","Collingwood","Adelaide","WCE","Brisbane",20,"Geelong","Sydney","GWS","Melbourne","Essendon","Carlt on" Data "Brisbane","Western Bulldogs","North Melbourne","Collingwood","Fremantle","Gold Coast","StKilda","WCE","Richmond","Hawthorn","Adelaide" Data "Pt Adelaide",21,"Western Bulldogs","GWS","Sydney","Fremantle","Geelong","Richmond","Brisbane","Gold Coast","Essendon","Adelaide" Data "WCE","Carlton","Melbourne","StKilda","Hawthorn","North Melbourne","Pt Adelaide","Collingwood",22,"Adelaide","Sydney","Western Bulldogs" Data "Pt Adelaide","Collingwood","Geelong","GWS","WCE","Essendon","Gold Coast","Carlton","Hawthorn","Melbourne","Brisbane","StKilda" Data "North Melbourne","Fremantle","Richmond",23,"North Melbourne","Brisbane","Melbourne","Collingwood","Fremantle","Essendon","GWS" Data "Geelong","Western Bulldogs","Hawthorn","Gold Coast","Pt Adelaide","StKilda","Richmond","Carlton","Sydney","Adelaide","WC" Sub selections For x = 1 To games If Eval(teamhome$(x)) > Eval(teamaway$(x)) Then Sel$(x) = teamhome$(x) Else Sel$(x) = teamaway$(x) EndIf Next x End Sub The bit where it comes unstuck is the Sub selections. I get the error "Expression Syntax" Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
CircuitGizmos![]() Guru ![]() Joined: 08/09/2011 Location: United StatesPosts: 1427 |
You have a mix of string information and integers in your DATA statements. Would you be able to reformat all of that to separate the strings from the integers? You would do READs to a string from the data containing string variables, and READs to an integer from the data containing integers. Also it is so much easier to read code when you put it in a quote. Click the "Add Quote" icon and that puts: (QUOTE)(/QUOTE) (except with square brackets) in your post. Paste your code between the keywords and you get pretty code displayed. Micromites and Maximites! - Beginning Maximite |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Hi Paul You need to 'split' your IF THEN, ELSE, ENDIF up (namely the line .... ELSE .....) So use: Sub selections For x = 1 To games If Eval(teamhome$(x)) > Eval(teamaway$(x)) Then Sel$(x) = teamhome$(x) Else Sel$(x) = teamaway$(x) EndIf Next x End Sub Enjoy coding the rest ![]() WW |
||||
CircuitGizmos![]() Guru ![]() Joined: 08/09/2011 Location: United StatesPosts: 1427 |
If you have: Essendon = 1 Brisbane = 2 Fremantle = 3 GoldCoast = 4 Those are variables. Essendon is set to the value of 1. If you make a data statement: DATA "Essendon", "Brisbane" (etc) The data statement contains strings. If you make a data statement like this: DATA Essendon, Brisbane (etc) The data statement contains integers, and in this example, it is the same as making a data statement like thus: DATA 1,2 Micromites and Maximites! - Beginning Maximite |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
@CircuitGizmos The DATA part of the code runs OK I think I read in the manual that the quotes in a DATA statement don't have to be there Eg Read thisstring$ Data Carlton thisstring$ will be assigned the string Carlton I will try WWs example. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Tried what WW said but with the same Error ?? Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |