Weekly Qbasic and Qb64 Lesson Topics
March 29, 2024, 03:09:50 am
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

PHP vs QB64 functions

Pages: [1]
  Print  
Author Topic: PHP vs QB64 functions  (Read 505 times)
5even
Newbie
*
Posts: 2


« on: August 18, 2011, 12:44:03 pm »

Hi.. not really sure where to post this as I looked over the categories and nothing seemed to fit. its not a tutorial and its not part of any lesson.. just more of a quesiton:
1st im pretty fluent in 5 major languages (yes I sometimes get them mixed up) but I am very very nestaligic when it comes to program. I just like the DOS feel of stuff (as I was an avid BBS'er and ran my own and even wrote a few doors).
I was estactic when i found that there was a basic program that actually worked in modern day windows. I was working with VBDos v1.0 until XP then it quit working. (No i cant stand dosbox as I want my apps to run on any system)
ok enough of that Tongue


What I am trying to do, and may be beyond the scope of QB64 but here goes.
My favorite language is PHP, one because of all the goodies they have. Two functions they have that I would like to create for QB64
SERIALIZE/UNSERIALIZE and SPLIT (or explode same thing)

However, I can do the serialize if i can just get the split to work.
Split takes a delimited string (usually comma) and returns it as an array
example text$ = SPLIT("THIS,IS,A,TEST", ",")
would give the following:
text$(1) = "THIS"
text$(2)="IS"
and so forth

my problem is I do not remember how old basic returns an array from a function (if it is even possible)

currently I have it set as
FUNCTION SPLIT(TEXT$, DELIM$)

where TEXT$ is the delimited string and DELIM$ is what is used to split it (see above)

how do you have a function return an array value?


sorry tab,enter by accident sending this post.. stand by for the rest
« Last Edit: August 18, 2011, 12:48:12 pm by 5even » Report Spam   Logged

Share on Facebook Share on Twitter

5even
Newbie
*
Posts: 2


« Reply #1 on: August 18, 2011, 01:16:35 pm »

here is the first experiment: THIS WORKS
I just dont want to do it this way

Code:
DIM SHARED STRIPPED$(100) 'ANY NUMBER BUT 100 IS PLENTY
CALL split("THIS,IS,A,TEST", ",")
PRINT STRIPPED$(1)
PRINT STRIPPED$(2)
'// RESULT:
'// THIS
'// IS
END


'= SPLITS A STRING INTO AN ARRAY BY DILEMETER
'= @HAYSTACK$ STRING THAT NEEDS TO BE SPLIT UP
'= @NEEDLE$ THE SEPARATOR USED
SUB split(haystack$, needle$)
i=1
max = len(haystack$)
do
    'grab everything to the left of the needle
    needle_pos = instr(haystack$,needle$)-1
    STRIPPED$(i) = left$(haystack$,needle_pos)
    'delete that portion from haystack
    haystack$ = right$(haystack$,len(haystack$)-needle_pos-1)
    i = i + 1   
loop until i = max

END SUB


The above code will give an idea what I am shooting for. It works fine, but something of this nature should be a function and not a sub. I do not know now to get qb64 to function an array result.

With the above code (if it was a function) if i use the line:  STRIP$ = STRIPPED$ i get a subscript error. (dont remember the exact error)

so is it possible to turn this into a function?
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #2 on: August 18, 2011, 07:18:18 pm »

5even,
 Welcome to the forum, 5even,...and this is fine where you posted.
 The only problem is, I don't know enough, even come close to it, to be able to help,...In relation to that, I think your best bet would be to post this at
http://www.qb64.net you probably will get a more prompt answer,..
 You can copy/paste, the same message, to your post at qb64.net , once you have the editor open, so yu don't have to re-write the whole  thing,..
 I am interested, in what you can tell me about PHP,...I am just starting to try to learn more about it,..actually I am trying to learn if it is possible to create a script, that could run qb64 programs or games, on a web site (online),...
 This same thread is fine,..

http://creativeminds.webege.com/phpBB3/index.php
  I did find a java script, applett, that runs qbasic and dos, online (PC emulator), but not very well,...
http://creativeminds.webege.com/RETRO-04/retro-0.4/retroapplet.html You may have some ideas ?
 Any way hope to here more from you, and again welcome, and thanks for joining,
from Garry (admin)
« Last Edit: August 18, 2011, 07:21:01 pm by GarrisonRicketson » Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy