|
Post by xxgeek on Jul 16, 2022 1:23:34 GMT
Don't let it discourage you. After reading your code in the first post I was amazed at how you went about it. It works, and it is just as instant getting the results as the code I posted. Personally, inefecient code will push you to even better. You should see all the code I have that could be far better. The main thing is you DID figure out a way to get done what you wanted to do. Efficiency will come when you tire of all the extra typing. Did for me anyway. Still end up taking the wrong route sometimes regardless.
I'll stare at my code rereading it and then viola a new way comes to mind. I'll try things and not even understand what is actually being done and again viola, it works for some reason lol Then I keeping reading the code to figure out why it works.
You obviously have the brains for it. Keep at it.
btw - Did you use a different basic before JB?
|
|
|
Post by jarychk on Jul 16, 2022 3:04:22 GMT
A another character to keep out of the condensed string, and now the string-condensing part of the code turned into a function. The more characters to exclude from the result, the more that the idea from tsh73 using a reference list of acceptable characters becomes a more practical idea. The ref list of acceptable characters should be shorter than the line of code with a IF holding so many conditions. Currently this example will exclude single-space, comma, and period-mark. (Maybe the dash and the forward and back slashes should also be put in as conditions for character exclusion.)
Reason for taking out certain characters and condensing is to possibly use the results as part of naming files.
print "Another string condense example try." print "Example strings could be 'july 15, 2022' and march 10, 2021" print " Let us use non function first." print "To end the program, just enter the an empty string (meaning press" print "Enter key without typing in anything)." print [goagain]
print "Give us a date in the form of 'MONTH dd, yyyy', for which MONTH" print "is any spelling you wish for the month. " : input gd$ cls
IF gd$="" then END
REM gd$ 'string or date user gives as input, string which is to be shrunk LET shrd$="" 'the shrunken string being rebuilt LET ch$="" 'any character to add to the string being built
sz=len(gd$)
'HERE was the shrinkage code until designer 'changed it into a function.
PRINT "WELL NOW WE'VE the date of ";gd$;" shrunken down to ";shrd$(gd$) PRINT goto [goagain]
END
function shrd$(gd$) 'meaning of variable name, SHRink Date according to lowering case of the shown capital cases. 'HERE DO THE SHRINKING sz=len(gd$) for i=1 to sz if mid$(gd$,i,1)=" " or mid$(gd$,i,1)="," or mid$(gd$,i,1)="." then ch$="" else ch$=mid$(gd$,i,1) shrd$=shrd$+ch$ 'the assigning will become finished HERE. end if next i end function
|
|
|
Post by tsh73 on Jul 16, 2022 9:31:07 GMT
I just noticed if condition holds, mid$(gd$,i,1) is not going to be used. Neither ch$. So, line ch$="" serves no purpose.
(but thing that not used does not prevents program from working right ;) )
|
|
|
Post by jarychk on Jul 16, 2022 16:53:19 GMT
I just noticed if condition holds, mid$(gd$,i,1) is not going to be used. Neither ch$. So, line ch$="" serves no purpose. (but thing that not used does not prevents program from working right ) I currently do not understand, although some occasions occur when I get confused between double alternative decision structure and single alternative decision structure.
|
|
|
Post by jarychk on Jul 16, 2022 16:54:47 GMT
I just noticed if condition holds, mid$(gd$,i,1) is not going to be used. Neither ch$. So, line ch$="" serves no purpose. (but thing that not used does not prevents program from working right ) YES! It is supposed to serve the purpose of being empty. Just for the condition.
|
|