Skip to content

Commit ea48d22

Browse files
authored
Merge branch 'smallbasic:master' into master
2 parents 4dce83a + deccf2e commit ea48d22

File tree

8 files changed

+524
-143
lines changed

8 files changed

+524
-143
lines changed

_build/pages/android.markdown

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,47 @@ android.speak(text)
169169

170170
Performs text to speech (default is ENGLISH).
171171

172+
## HTTPS Web request
173+
174+
```smallbasic
175+
android.request(url, [postData, authToken])
176+
```
177+
178+
- `url`: The URL endpoint for the request.
179+
- `data` (optional): Data to send in the request body. If provided, the request method is `POST` with `Content-Type: application/json`. If omitted, the request method defaults to `GET`.
180+
- `token`: (optional): Bearer authentication token for a `POST` request.
181+
182+
The `REQUEST` function enables making HTTPS requests (either `POST` or `GET` methods), supporting secure connections that are not possible with the `OPEN` command.
183+
184+
**Note**: For desktop versions, you can utilize the `RUN` command with `curl` for similar functionality.
185+
186+
```
187+
import android
188+
189+
const endpoint = "https://llamafile/v1/chat/completions"
190+
const apiKey = "no-key"
191+
192+
func request(content)
193+
local post_data
194+
dim post_data.messages(0 to 1)
195+
post_data.model = "gpt-3.5-turbo"
196+
post_data.messages[0].role = "system"
197+
post_data.messages[0].content = "You are a helpful assistant"
198+
post_data.messages[1].role = "user"
199+
post_data.messages[1].content = content
200+
return array(android.request(endpoint, post_data, apiKey))
201+
end
202+
203+
while 1
204+
input "Question: ", prompt
205+
response = request(prompt)
206+
print response.choices[0].message.content
207+
wend
208+
```
209+
210+
The code snippet demonstrates how to use REQUEST to interact with a specified endpoint, providing necessary data and token for authentication.
211+
212+
172213
## How to edit and run a program
173214

174215
### Internal editor:

_build/pages/android_changelog.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ Android Changelog
55
[Home](/) > [Articles](/pages/articles.html)
66
:::
77

8+
**12.27 (25 April 2024)**
9+
10+
- Add new function android.request
11+
- Add new function TRANSPOSE()
12+
- Add experimental ioio-otg support
13+
- Fix download error when there are duplicate scratch.bas files
14+
- Fix TSAVE bug #205
15+
- Fix bug: LINEQN tolerance
16+
- Fix floating-point number round-precision bug
17+
- Fix redim regression
18+
- Fix: RTRIM changes input string
19+
820
**12.26 (31 March 2023)**
921

1022
- Fixed "0 IMP 0" returns now correct result 1 (Joe7M)

_build/pages/changelog.markdown

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Changelog
22
=========
33

4+
**12.27 (26 April 2024) **
5+
6+
- Add new function TRANSPOSE()
7+
- Allow modules to return objects with methods that take arguments
8+
- Fix TSAVE bug #205
9+
- Fix bug #149: Problem with big hex numbers in windows
10+
- Fix bug: LINEQN tolerance
11+
- Fix building on Cygwin
12+
- Fix floating-point number round-precision bug when converting a floating-point number to string.
13+
- Fix for RoundPrecisionBug
14+
- Fix linking issue on MSYS2
15+
- Fix parameter number error when calling a unit sub/func
16+
- Fix redim regression
17+
- Fix: RTRIM changes input string
18+
- Improvements for image.save()
19+
- Serial port improvements.
20+
- Show a runtime error if a module calls exit()
21+
- Bugfix for image.clip() and image.save()
22+
- Fix image save
23+
- Added mechanism for cleaning up resources when the associated map falls out of scope
24+
425
**12.26 (26 March 2023) **
526

627
- FLTK and SDL version numbers now included in SBVER

_build/pages/download.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
## Windows
1313

14-
[12.26](https://github.com/smallbasic/SmallBASIC/releases/download/12_26/smallbasic_12.26.zip){target="_blank"}
14+
[12.27](https://github.com/smallbasic/SmallBASIC/releases/download/12_27/smallbasic_12.27.zip){target="_blank"}
1515

1616
## Linux
1717

18-
- [SDL 64 bit AppImage - 12.26](https://github.com/smallbasic/SmallBASIC/releases/download/12_26/SmallBASIC-SDL_12.26-x86_64.AppImage){target="_blank"}
19-
- [FLTK 64 bit AppImage - 12.26](https://github.com/smallbasic/SmallBASIC/releases/download/12_26/SmallBASIC-FLTK_12.26-x86_64.AppImage){target="_blank"}
20-
- [Console 64 bit AppImage - 12.26](https://github.com/smallbasic/SmallBASIC/releases/download/12_26/SmallBASIC-Console_12.26-x86_64.AppImage){target="_blank"}
18+
- [SDL 64 bit AppImage - 12.27](https://github.com/smallbasic/SmallBASIC/releases/download/12_27/SmallBASIC-SDL_12.27-x86_64.AppImage){target="_blank"}
19+
- [FLTK 64 bit AppImage - 12.27](https://github.com/smallbasic/SmallBASIC/releases/download/12_27/SmallBASIC-FLTK_12.27-x86_64.AppImage){target="_blank"}
20+
- [Console 64 bit AppImage - 12.27](https://github.com/smallbasic/SmallBASIC/releases/download/12_27/SmallBASIC-Console_12.27-x86_64.AppImage){target="_blank"}
2121
- [Ubuntu 32 bit - 0.12.9](http://sourceforge.net/projects/smallbasic/files/Linux/0.12.9/smallbasic_0.12.9_i386.deb){target="_blank"}
2222
- [Raspberry PI - 0.12.6](http://sourceforge.net/projects/smallbasic/files/Linux/0.12.6/smallbasic_0.12.6_armhf.deb){target="_blank"}
2323

@@ -35,7 +35,7 @@
3535

3636
## Source code
3737

38-
[12.26](https://github.com/smallbasic/SmallBASIC/releases/download/12_26/smallbasic-12.26.tar.gz){target="_blank"}
38+
[12.27](https://github.com/smallbasic/SmallBASIC/releases/download/12_27/smallbasic-12.27.tar.gz){target="_blank"}
3939

4040
## Other releases
4141

pages/android.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,37 @@ <h2 id="text-to-speech">Text to speech</h2>
147147
<p>SPEAK</p>
148148
<div class="sourceCode" id="cb12"><pre class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true"></a>android.speak(text)</span></code></pre></div>
149149
<p>Performs text to speech (default is ENGLISH).</p>
150+
<h2 id="https-web-request">HTTPS Web request</h2>
151+
<div class="sourceCode" id="cb13"><pre class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true"></a>android.request(url, [postData, authToken])</span></code></pre></div>
152+
<ul>
153+
<li><code>url</code>: The URL endpoint for the request.</li>
154+
<li><code>data</code> (optional): Data to send in the request body. If provided, the request method is <code>POST</code> with <code>Content-Type: application/json</code>. If omitted, the request method defaults to <code>GET</code>.</li>
155+
<li><code>token</code>: (optional): Bearer authentication token for a <code>POST</code> request.</li>
156+
</ul>
157+
<p>The <code>REQUEST</code> function enables making HTTPS requests (either <code>POST</code> or <code>GET</code> methods), supporting secure connections that are not possible with the <code>OPEN</code> command.</p>
158+
<p><strong>Note</strong>: For desktop versions, you can utilize the <code>RUN</code> command with <code>curl</code> for similar functionality.</p>
159+
<pre><code>import android
160+
161+
const endpoint = &quot;https://llamafile/v1/chat/completions&quot;
162+
const apiKey = &quot;no-key&quot;
163+
164+
func request(content)
165+
local post_data
166+
dim post_data.messages(0 to 1)
167+
post_data.model = &quot;gpt-3.5-turbo&quot;
168+
post_data.messages[0].role = &quot;system&quot;
169+
post_data.messages[0].content = &quot;You are a helpful assistant&quot;
170+
post_data.messages[1].role = &quot;user&quot;
171+
post_data.messages[1].content = content
172+
return array(android.request(endpoint, post_data, apiKey))
173+
end
174+
175+
while 1
176+
input &quot;Question: &quot;, prompt
177+
response = request(prompt)
178+
print response.choices[0].message.content
179+
wend</code></pre>
180+
<p>The code snippet demonstrates how to use REQUEST to interact with a specified endpoint, providing necessary data and token for authentication.</p>
150181
<h2 id="how-to-edit-and-run-a-program">How to edit and run a program</h2>
151182
<h3 id="internal-editor">Internal editor:</h3>
152183
<ul>

pages/android_changelog.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ <h1 id="android-changelog">Android Changelog</h1>
6868
<div class="siteSub">
6969
<p><a href="/">Home</a> &gt; <a href="/pages/articles.html">Articles</a></p>
7070
</div>
71+
<p><strong>12.27 (25 April 2024)</strong></p>
72+
<ul>
73+
<li>Add new function android.request</li>
74+
<li>Add new function TRANSPOSE()</li>
75+
<li>Add experimental ioio-otg support</li>
76+
<li>Fix download error when there are duplicate scratch.bas files</li>
77+
<li>Fix TSAVE bug #205</li>
78+
<li>Fix bug: LINEQN tolerance</li>
79+
<li>Fix floating-point number round-precision bug</li>
80+
<li>Fix redim regression</li>
81+
<li>Fix: RTRIM changes input string</li>
82+
</ul>
7183
<p><strong>12.26 (31 March 2023)</strong></p>
7284
<ul>
7385
<li>Fixed “0 IMP 0” returns now correct result 1 (Joe7M)</li>

0 commit comments

Comments
 (0)