September 26, 2020, 06:58:17 pm

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


RESOURSE FILES

Started by KQ4TX, September 26, 2009, 09:06:04 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

KQ4TX


GENTLEMAN

I PURCHASED CREATIVE BASIC THINKING MAYBE BUT MAYBE THIS VERSION WOULD LET ME
RESOURSE IMAGE FILES AND WAV FILES INTO MY COMPILED PROGRAM. CREATIVE BASIC LOOKS JUST LIKE MY iBASIC PROGRAM WHICH WON'T LET ME RESOURSE BECAUSE IT IS A SHAREWARE VERSION. MY QUESION IS, HAS ANYONE TRIED TO RESOURSE FILES IN THIS VERSION. IS THERE
A FULL VERSION OF THIS PROGRAM THAT WILL LET ME SOLVE THIS PROBLEM.
THANKS
JOE

LarryMc

Did you read the Resouce Files section of the Creative Basic help file?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

KQ4TX


YES iI DID AND IT SAID IF THIS IS A SHAREWARE VERSION RESOURSES COULD NOT BE USED.
THE AD DIDN'T SAID CREATIVE BASIC WAS A SHAREWARE VERSION EVEN THOUGH IT LOOKS JUST LIKE IBASIC STANDARD 2.02D. THE ONE GOOD THING ABOUT USING THIS PROGRAM
IS I CAN TALK TO ALL PRO'S OUT THERE.OH WELL IT WAS JUST 14 DOLLARS.

LarryMc

September 26, 2009, 09:35:51 am #3 Last Edit: September 26, 2009, 10:01:31 am by Larry McCaughn
Although I don't use it I have CBasic 1.0.
It allows you to add resources to your .exe.

So, I'm not understanding why you say you can't.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

KQ4TX


OK MR LARRY NOW I KNOW IT MUST BE ME. IF I GO TO THE MENU AND CLICK ON RESOURSE
AND GO TO TYPE SCALABLE IMAGE AND ENTER THE FILENAME AND PRESS ADD.
WHEN I COMPILE THE PROGRAM IT COMES UP WITH A ERROR, COMPILING RESOURSE.
WHAT AM I DOING WRONG?

LarryMc

Three questions?
Did you use Choose to select the image?
what was the extension of the image file?
what did you enter for the ID?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

The two things that I can do to get that error message is leave the ID blank or enter a non-existant image file.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

KQ4TX


I SENT A REPLY THAT DIDN'T POST.
OK LET ME INVESTIGATE AGAIN. THE MAIN THING IS IT SHOULD WORK AND THAT ALL I WANTED TO KNOW. IF NOT I'LL BE BACK
THANKS
JOE

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Yes best option is read help topic about resources and dont forget only in compiled (buildet) exe
file you can see how resource works not in runtime mode in editor when you test your program.

Aurel ;D
forum for hobby programming:<br />https://aurelsoft.ucoz.com

KQ4TX


OK  I GOT THE RESOURCE TO WORK FOR AN IMAGE
I HAD TO CHANGE MY PROGRAM FROM THIS PIC1= loadimage(GETSTARTPATH + "COOL18.JPG", @IMGSCALABLE )TO THIS PIC1= loadimage ("COOL18", @IMGSCALABLE ) THEN COMPILE.
ID=COOL18, TYPE = @IMGSCALABLE , FILENAME =SELECT FILE LOCATION,  PRESS THE ADD BUTTON.
NOW I WANT TO RESOURCE A WAV FILE.YOU SAID READ THE HELP FILE SO HERE IT IS
For example you may want to include wave files in your project and later load the sounds from the
resources using LOADRESOURCE. In this case it is recommended you use a string type identifier such as WAVE or SOUND as the custom type.

success = LOADRESOURCE(ID, Type, Variable)
Loads a resource from the executable and places either a copy of the resource, or an integer pointer to the resource, in the variable specified.
ID is either a numeric or string identifier to the resource, TYPE is a numeric or string type and it stores the info in 'variable.

I CHANGED MY PROGRAM FROM THIS
HANDLE = GETSTARTPATH  + "SH21.WAV"

TO THIS
HANDLE=  LOADRESOURCE("SH21",WAVE,"SND")
I'VE TRIED EVERY COMBINATION AND ALL I GET IS "ILLEGAL ASSIGNMENT" OR ERRORS,ETC
I USED SND AS MY VARIABLE
MAYBE SOMEONE CAN SOLVE THE PROBLEM
JOE







KQ4TX


BY THE WAY, SORRY I MISSPELLED RESOURCE IN THE TOPIC.
JOE

LarryMc

September 27, 2009, 01:53:52 pm #12 Last Edit: September 27, 2009, 01:55:47 pm by Larry McCaughn
So let's see if I understand you correctly.
You are trying to load the resource with:
Code Select
HANDLE=  LOADRESOURCE("SH21",WAVE,"SND")
from the help file:
Quotesuccess = LOADRESOURCE(ID, Type, Variable)

What value did you define WAVE to be?  The help file states it has to be a number over 255

The help file also says:
QuoteIf 'variable' is a STRING (or ISTRING) variable the contents of the resource will be copied into the string.

"SND" is not a string variable; it is a literal string.
A string variable would be defined this way:
Code Select
def snd as string
So your statement would be more correct if you had it as:
Code Select
def snd as string
HANDLE=  LOADRESOURCE("SH21",WAVE,SND)

But unless your wave file is 255 or less bytes long it still isn't going to work because a string variable can only hold 255 characters.
You're either going to have to define an ISTRING large enough to hold it or use a MEMORY variable.

That's about as much as I can help you.
If it were me I would handle it exactly the way I know it would work already(the way I previously explained to you) and let it go at that.

Good luck.

Larry

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

SnarlingSheep

Here's what you need to do.
Add a resource and use these values:
ID= 100, Type= Custom, Custom Type= WAVE
Then select your wav file and click the Add button.

Here's what should be a working example:
Code Select

DEF win:WINDOW
DEF mySound:MEMORY
DEF success:INT

window win,100,100,245,202,@caption|@minbox,0,"Wave Resource Test",MainWndProc
control win,"B,Play,84,142,72,24,0x800000,1"
control win,"B,Exit,160,142,75,24,0x800000,2"
centerwindow win

'success will just tell you if the resource was loaded.
'100 is the resource ID.
'WAVE is the Custom Type.
'mySound is the memory variable the sound data is loaded into.
success = loadresource(100,"WAVE",mySound)
if success = 0
messagebox win,"Unable to load Wave Resource", "Wave Resource Test"
endif

run = 1
waituntil run = 0
'Make sure to free the MEMORY variable
freemem mySound
closewindow win
end

MainWndProc:
select @class
case @idcontrol
select @controlid
case 1
playwave mySound,@SNDASYNC
case 2
run = 0
endselect
case @IDDESTROY
run = 0
case @idclosewindow
run = 0
endselect
return

KQ4TX


OK SNARLINGSHEEP YOU CAME TO SAVE THE DAY.
AFTER 150 VIEWS I WOULD THINK SOMEONE WOULD HAVE THE ANSWER.
THANKS SO MUCH
LET ME TRY IT OUT. IT DOES MAKE SENSE. I WAS CLOSE BUT STILL LOST
I'M USING DOZENS IF IMAGES AND WAV FILES IN THIS PROJECT I'M WORKING ON.
I THOUGHT IT WOULD BE NICE TO PLACE THEM INTO MY COMPILED PROGRAM.
I'LL GET BACK IF I DON'T GET IT WORKING.
THANKS AGAIN
JOE