QB64.org Forum

Active Forums => Programs => Topic started by: eoredson on July 27, 2018, 01:53:49 am

Title: The SICK project
Post by: eoredson on July 27, 2018, 01:53:49 am
Attached is The Symbolic Instruction Code Kit which is a pseudo-BASIC interpreter written in
BASIC for QB64 windows..

The Symbolic Instruction Code Kit, which contains a QB64 program named SIC64.BAS
and several smaller utility programs. The source code is public domain and can be
found on several sites, including, www.filegate.net and www.keepandshare.com

This program uses a recursive descent parser to interpret a psuedo-basic language
written in a line number oriented fashion and can be used for small programming chores.

The archive also contains some further imbedded .zip files which contain several
QB64 sample programs, and some .SIC programs which are used by the SIC engine.
Title: Re: The SICK project
Post by: bplus on July 27, 2018, 10:04:41 am
Hi Erik,

Is there anything new here that is not already included in the "Samples Gallery?

Actually it looks to be a couple of KB smaller and has version 2 attached to the zip.
Title: Re: The SICK project
Post by: eoredson on July 27, 2018, 07:27:00 pm
This is a new version with updates to some color prompts fixed, and an addition to support
file attributes for compressed/encrypted files. (v64 r5.2)

Erik.
Title: Re: The SICK project
Post by: STxAxTIC on July 29, 2018, 09:47:03 am
Hello Erik,

In light of the sxmath plug over at the "power function" thread, I decided to return the favor with a slightly tweaked SIC64.bas file. The changes are light and surgical:

At the top and bottom (respectively):
Code: QB64: [Select]
  1. REM $Include: 'sxmath.bi'
  2. REM $Include: 'sxript.bi'
  3. ...
  4. REM $Include: 'sxmath.bm'
  5. REM $Include: 'sxript.bm'
  6.  

...And somewhere in the middle:
Code: QB64: [Select]
  1.         CASE "SXR"
  2.             CALL GetToken3
  3.             CALL GetToken
  4.             CALL Parse1(Temp#)
  5.             Out3 = SxriptEval$(Out3)
  6.             CALL GetToken4
  7.             LastToken = False
  8.  

... And that embeds the full-blown Sxript language into your project. It's dressed up as the "SXR" function of a single string argument. To test it out, I was doing a little calculus in the SIC terminal. First I dragged over the Sxript calculus header:

Code: QB64: [Select]
  1. func(deriv, {
  2.   (([x]([y]+[z])) - ([x]([y]-[z]))) / (2*[z])
  3. }):
  4.  
  5. func(itersolve,{
  6.   [y] - ([x]([y])) / deriv([x],[y],[z])
  7. }):
  8.  
  9. func(newtonsolve, {
  10.   sub({
  11.     let(fxn,[x]):
  12.     let(ans,[y]):
  13.     for(<k,1,[z],1>, {
  14.       let(ans,itersolve([fxn],[ans],0.001))
  15.     }):
  16.     print_[ans]
  17.   })
  18. }):
  19.  
  20. func(lhopital,{
  21.   deriv([x],[z],.001) / deriv([y],[z],.001)
  22. }):
  23.  
  24. func(integral,{
  25.   sub({
  26.     let(fxn,[x]):
  27.     let(tot,0):
  28.     let(step,[t]):
  29.     for(<j,[y],[z],[step]>,{
  30.       let(tot, [tot] + [step] * [fxn]([j]) )
  31.     }):
  32.     print_[tot]
  33.   })
  34. }):
  35.  
  36. print_`calculus.txt':
  37.  

Next I wrote my first *.sic program:
Code: QB64: [Select]
  1. 10 PRINT SXR("include(`calculus.txt')")
  2.  
  3. REM Define the problem to solve.
  4. 20 p$ = "[x]^3 - 10"
  5.  
  6. REM Set guess value.
  7. 30 g = 1.5
  8.  
  9. REM Set number of iterations.
  10. 40 i = 5
  11.  
  12. 50 a$ = SXR("func(problem,{" + p$ + "})")
  13.  
  14. 60 PRINT SXR("newtonsolve(problem," + STR$(g) + "," + STR$(i) + ")")
  15.  

Note that all of the Sxript-ish stuff is stashed away in its own parens and the BASIC user doesn't need to really understand it. That is, the editable lines are 20, 30, and 40. (There are other style remarks implied in the code that are not spelled out.)

... and voila, it does its job of computing the cube root of 10 in this case. See the screenshot below, along with all files needed to replicate the changes. Stick the *.bi/bm files in the same level as the *.BAS at compile time.



Title: Re: The SICK project
Post by: eoredson on August 04, 2018, 10:32:06 pm
Interesting.. Could you bundle up the above files into a separate .zip file please?

Thanks, Erik.
Title: Re: The SICK project
Post by: Aurel on August 06, 2018, 03:11:32 pm
hey static
do you ever use maxwell formulas?
Title: Re: The SICK project
Post by: STxAxTIC on August 07, 2018, 12:06:40 am
Hi Erik and Aurel

(i) So I'm a bit confused as to why (Erik) you would ask me to re-combine the files above in an undoubtedly more confusing ZIP file. What's on your mind in this direction?

(ii) Maxwell "formulas" are a strange term... There are Maxwell "relations", which have to do with the second derivative of thermodynamic potentials, but I think you're really referring to Maxwell's "equations" of electromagnetism. So put it this way... I routinely address and manipulate Maxwell's equations in more (or fewer) dimensions than it requires to send you this message. Tensor calculus ftw bro! (Did you have a question, or just taking the temperature of my ego?)
Title: Re: The SICK project
Post by: Aurel on August 07, 2018, 12:15:28 pm
but I think you're really referring to Maxwell's "equations" of electromagnetism.

Hi STATIC
Yes about electromagnetic
I found that those formulas are used to calculate current density on metal surfaces
In simple words:
when electromagnetic wave hit this metal surface then as we known electric current arrive .
it is about microstrip antennas.
I found few codes (in matlab or in python) but nothing in BASIC.
Did you ever made such a calculations?